![]() |
Controllers in subfolders, How do I specify an index? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Controllers in subfolders, How do I specify an index? (/showthread.php?tid=55852) |
Controllers in subfolders, How do I specify an index? - El Forum - 11-13-2012 [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. Controllers in subfolders, How do I specify an index? - El Forum - 11-13-2012 [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' Controllers in subfolders, How do I specify an index? - El Forum - 11-13-2012 [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 Controllers in subfolders, How do I specify an index? - El Forum - 11-13-2012 [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-guide/general/controllers.html#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. Controllers in subfolders, How do I specify an index? - El Forum - 11-13-2012 [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 Controllers in subfolders, How do I specify an index? - El Forum - 11-24-2012 [eluser]ahmed.alsiddig[/eluser] me too need this thanks for helping guys |