CodeIgniter Forums
How to get default_controller value - 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: How to get default_controller value (/showthread.php?tid=15725)



How to get default_controller value - El Forum - 02-12-2009

[eluser]LifeSteala[/eluser]
Hi,
Is there a way to get the default_controller value in a controller? I tried,

Code:
config_item('default_controller');

but that didn't work.

Thanks
LS


How to get default_controller value - El Forum - 02-12-2009

[eluser]TheFuzzy0ne[/eluser]
Code:
include(APPPATH . "config/routes.php");
echo $route['default_controller'];

should do it. I'm sure there's an easier way, but I'll be darned if I can find it!


How to get default_controller value - El Forum - 02-12-2009

[eluser]LifeSteala[/eluser]
Cool, that works! Thanks!


How to get default_controller value - El Forum - 02-12-2009

[eluser]TheFuzzy0ne[/eluser]
Ah-ha! There is a better way!
Code:
$this->router->default_controller; // Contains the default controller name.

Hope this helps.


How to get default_controller value - El Forum - 02-12-2009

[eluser]LifeSteala[/eluser]
Oh Cool! Well done! Thanks once again.