Controllers in subfolders, How do I specify an index? |
[eluser]jhyland[/eluser]
I was making a controller "admin.php", thinking it wouldn't get all THAT long.. Well now its about 2000 lines of code, so its time to break it down. I created an application/controllers/admin folder for all admin controllers, and then, for example, a application/controllers/admin/accounts.php controller that will process all account related admin functions. My question is, when they just go to mysite.com/index.php/admin/ .. That puts them into the admin folder, but how can I specify a default controller for that folder? Thanks in advance.
[eluser]adamck[/eluser]
I think you need to set something in the Routes config for that. Code: $route['admin'] = "admin/yourindex"; This will make http://yoursite.com/admin load 'application/controllers/admin/yourindex.php'
[eluser]jhyland[/eluser]
[quote author="adamck" date="1352813344"]I think you need to set something in the Routes config for that. Code: $route['admin'] = "admin/yourindex"; This will make http://yoursite.com/admin load 'application/controllers/admin/yourindex.php'[/quote] Hah, you're awesome! Thanks champ
[eluser]Go-Trex[/eluser]
There is an explanation in the official user guide about placing controllers in sub-folders. You can find the explanation here: http://ellislab.com/codeigniter/user-gui...subfolders I use this method for a while now and most of the times it is suitable, but when you are combining this with a multi-language interface where the first uri-segment is the countrycode you need to make changes to the default routes. Keep that in mind for future projects.
[eluser]Aken[/eluser]
In newer versions of CI, the $route['default_controller'] option will be used as a default if one is set. For example: Code: // routes.php
|
Welcome Guest, Not a member yet? Register Sign In |