I have a admin folder set up in my controllers directory, under that i have 3 seperate sub-folders with controllers inside of them.
-- Controllers
---- Admin
------ Dashboard
-------- dashboard.php
-------- file.php
------ Members
-------- members.php
-------- file.php
------ Settings
-------- settings.php
-------- file.php
I tried routing it in the routes.php file like this
$route['admin/(:any)/(:any)'] = 'admin/$1/$2';
$route['admin/(:any)'] = 'admin/$1/$1';
$route['admin'] = 'admin/index';
What do I do to fix this?
I was facing problem with
4-5 levels
ofsub-directories
(like /controllers/folder1/folder2/folder3/folder4/my-controller) and change the while loop fromto
It works for me.
The above one is ok for
2-3 sub-directories
but not for4-5 sub-directory
hierarchy.For Codeigniter 3.x compatibility: The usage of the EXT constant has been deprecated since dropping support for PHP 4. There’s no longer a need to maintain different filename extensions and in this new CodeIgniter version (3.x), the EXT constant has been removed. Use just ‘.php’ instead.
So the new MY_Router.php:
"Out of the Box" codeigniter does not support multiple subdirectory levels in your controllers directory, just one.
There is a way to extend the routing class to support this, check this blog entry.
This code was already on the internet but i modified it to make it work for codeigniter 2.1
See the old source here: http://glennpratama.wordpress.com/2009/10/20/multi-level-subfolder-for-controller-in-codeigniter/
Make a new file MY_Router.php in the application/core directory, copy the following code in it: