CodeIgniter Forums
How to "load" one controller from another? - 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 "load" one controller from another? (/showthread.php?tid=26769)



How to "load" one controller from another? - El Forum - 01-22-2010

[eluser]Jakobud[/eluser]
I'm a bit of a CodeIgniter newb, so bare with me...

It seems like a basic question, but I haven't seen anything like this in any tutorials or screencasts. This is what I have:

When you visit my site, it loads the 'site' controller by default. The first thing it does is check if you are logged using session data. If you are not logged in, then I want to goto the login controller. So my question is, how do I "goto" the login controller from within the site controller? I don't see anything in the UserGuide or Wiki about 'loading' controllers.

Do I need to just do a simple redirect?

Code:
header('Location: '.base_url.'/login' );

Sorry maybe this is an obvious question, but I'm having a hard time understanding how some things on a CI site tie together.


How to "load" one controller from another? - El Forum - 01-22-2010

[eluser]anthrt[/eluser]
You have the idea right.

Check the redirect function: http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html (scroll to the bottom)


How to "load" one controller from another? - El Forum - 01-22-2010

[eluser]Jakobud[/eluser]
Ah that's exactly what I was looking for. Thanks!