CodeIgniter Forums

Full Version: Controllers in nested sub-folders
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]pkorzeniewski[/eluser]
Hi,

Is it possible to put controllers into nested sub-folders - i.e:

/controllers/subdir1/subdir2/my_controller.php

and call it like:

www.example.com/subdir1/subdir2/my_controller ?

It doesn't work for me and I don't know if I'm doing something wrong or CI doesn't support nested sub-folders.

Regards,
Peter

El Forum

[eluser]Jelmer[/eluser]
It's actually one of the few weak points of the User Guide, it's not made explicit that only one level of subfolder is supported. By default you can't use more then 1 level of depth, only way to support more levels is to extend the Router class yourself.

El Forum

[eluser]pkorzeniewski[/eluser]
[quote author="Jelmer" date="1271216683"]It's actually one of the few weak points of the User Guide, it's not made explicit that only one level of subfolder is supported. By default you can't use more then 1 level of depth, only way to support more levels is to extend the Router class yourself.[/quote]

Yep you're right, I looked into Router class and it doesn't support nested subfolders however I changed it a little and now it does - if someone encounters similar problem, in attachment you'll find extended Router class with nested subfolders support, just put MY_Router.php into application/libraries folder.

El Forum

[eluser]codeigniterzzz[/eluser]
pkorzeniewski: i copied that code into the application/libraries folder, but the nested controller folders aren't being recognized and i get a 404.

El Forum

[eluser]CroNiX[/eluser]
That was written in 2010. I'm sure it was for an older version of CI.

El Forum

[eluser]codeigniterzzz[/eluser]
well where's a new version...