I have a subdirectory in my controllers folder - possibly to set default controller? |
I have created a subdirectory called 'admin' in my application/controllers directory. I've got some controllers in there yes sir:
Code: application/controllers/admin/Dashboard.php I'm wondering if it's possible to define a default controller::method for that subdirectory in case the url does not specify anything beyond http://example.com/admin For example, how would I route requests for http://example.com/admin to application/controllers/admin/Dashboard.php? I really hope I don't have to resort to defining a default controller for every subdirectory in my controllers directory via extensive changes to config/routes.php. Can anyone tell me if this is possible?
default_controller applies to all directories. If you set it to 'Dashboard', then application/controllers/Dashboard.php will be the default for example.com/ and application/controllers/admin/Dashboard.php will be the default for example.com/admin/
(07-23-2015, 05:12 PM)sneakyimp Wrote: I have created a subdirectory called 'admin' in my application/controllers directory. I've got some controllers in there yes sir: You can do something like this: PHP Code: $route['admin'] = 'admin/dashboard';
Romanian CodeIgniter Team :: Translations :: Comunity :: Developers
http://www.codeigniter.com.ro (07-24-2015, 06:38 AM)Narf Wrote:(07-24-2015, 06:28 AM)Dracula Wrote: You can do something like this: Then I apologize.
Romanian CodeIgniter Team :: Translations :: Comunity :: Developers
http://www.codeigniter.com.ro
Hm. It would seem that a default controller in a subdirectory cannot have methods other than index?
For example, I have a subdirectory with a default controller in it: PHP Code: // application/controllers/subdir/Welcome.php http://example.com/subdir http://example.com/subdir/foo http://example.com/subdir/bar However, I get 404/not found for both the foo and bar urls. I am forced to define other controller classes to get those urls served. Is this supposed to be the case? Is there no way to define a default controller in a subdirectory that handles *all* requests for that subdir?
I would create A core/MY_Router.php for CI3
Link MY_Router.php And use this PHP Code: <?php Then you can use default controller like $route['default_controller'] = 'admin/dashboard';
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
|
Welcome Guest, Not a member yet? Register Sign In |