Welcome Guest, Not a member yet? Register   Sign In
How to set default controller for sub-directory in controllers
#1

[eluser]gunnarflax[/eluser]
Hi! I have a multilevel-directory structure of my controllers directory. The user guide says that this is fully possible, all I have to do is set a default controller for the sub-dir in the config. The thing is that there is only one key called 'default_controller' and I can't find anywhere how the extra default controller should be named. What should I call it? And how do I need to configure my routes?

Thanks!
#2

[eluser]brucebat[/eluser]
Would you not put the next parameter of default_controller in the controller you loaded.

So that when the first controller is loaded it will then load another?
#3

[eluser]gunnarflax[/eluser]
Don't think so. The default controller functions in the way that if the url doesn't contain any url-segment for the controller it loads the default one. So if my folder structure is like this:
Code:
-- controllers
----- subdir (folder)
-------- admin
----- home
----- blog
and the url looks like this:
Code:
http://www.example.com/
it will load the default controller set by me:
Code:
$config['default_controller'] = 'home';
So every subdirectory should have a default controller or else if I type in this url:
Code:
http://www.example.com/subdir/
I still get the controller 'home'. So to not have to write:
Code:
http://www.example.com/subdir/admin/
I must set a default controller for the subdirectory as well and configure my routes (http://ellislab.com/codeigniter/user-gui...subfolders). But I do not know how. Any ideas?
#4

[eluser]intractve[/eluser]
I do this by...

In routes.php
Code:
$route['subdir'] = 'subdir/admin';
$route['subdir/(:any)'] = 'subdir/$1';
#5

[eluser]gunnarflax[/eluser]
Thanks! That did wonders!
#6

[eluser]Caio[/eluser]
[quote author="intractve" date="1309765818"]I do this by...

In routes.php
Code:
$route['subdir'] = 'subdir/admin';
$route['subdir/(:any)'] = 'subdir/$1';
[/quote]

agreed! that always works best.




Theme © iAndrew 2016 - Forum software by © MyBB