4

As I read the doc, controllers in CodeIgniter are supposed to support multiple level subfolders, but as far as I have tested, it is impossible to work after first a first level folder.

By example:

mysite.dev/ (index page, default controller home.php, works)

mysite.dev/admin/ (admin section, in admin/home.php, works)

mysite.dev/admin/manage/ (in admin/manage/home.php, do not work)

I am trying to know why and how to make it work on multiple level sub folders?

Thanks in advance!

1
  • Did you try using a route to point to the controller 2 levels deep? Commented Nov 5, 2012 at 21:00

1 Answer 1

3

CI only allows one sub-dir level. However, you can emulate this pattern with routes file as @Brendan says:

Controllers:

welcome.php
admin/admin.php
admin/manage.php

Routes file:

$route['admin/manage/:any'] = "admin/manage/$1";
$route['admin/admin'] = 'admin/home.php';

You can implement some changes to the hardcode to get works as expected: http://codeigniter.com/forums/viewthread/190563/

Sign up to request clarification or add additional context in comments.

4 Comments

Is there a way to make it automatic? Like I won't have to add every route for every seconth-level controller?
CI does in fact support subdirectories for controllers.
@WesleyMurch, yep, it does, but one subdir level
Ah I see, looks like you're right (and I misread your comment about that).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.