Welcome Guest, Not a member yet? Register   Sign In
setting a sub-folders default_controller in application/config/routes.php
#1

[eluser]Unknown[/eluser]
Lets say that I have a sub-folder in my controller directory for organizations sake at system/application/controllers/subfolder/ and I am trying to specify a default controller to run when a user accesses http://localhost/subfolder/.

http://ellislab.com/codeigniter/user-gui...subfolders says the way to do this is:
Quote:Each of your sub-folders may contain a default controller which will be called if the URL contains only the sub-folder. Simply name your default controller as specified in your application/config/routes.php file
However I can't find any example of this being put into use.

When I look at $route['default_controller'] = 'welcome'; and some other code samples I could only come up with one dead-end option of $route['subfolder/default_controller'] = 'test'; which was based off http://ellislab.com/codeigniter/user-gui...uting.html saying default_controller was a reserved route.

So is it possible to set the default controller for http://localhost/subfolder as 'test' and not have to use http://localhost/subfolder/test/ while keeping a different default controller for http://localhost/
#2

[eluser]Unknown[/eluser]
Ahh sleep brings success. The variable $route['default_controller'] = "welcome"; in application/config/routes.php specifies just the name of the controller that it will attempt to load at any folder level including sub-folders. I didn't think I should have two controllers with identical names but if I placed a welcome controller into my sub-folder and changed the view it calls then http://localhost/subfolder/ shows the subfolders welcome and http://localhost/ shows the main controller directories welcome controller.

I'm just going to rename the expected controller from welcome to main so I have one of those in every sub-folder I make.
#3

[eluser]atw[/eluser]
Wow, that is awesome! And i fixed my issue (trying to make an admin module)!

Thank you for this insight...




Theme © iAndrew 2016 - Forum software by © MyBB