![]() |
Call one controller from another controller - 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: Call one controller from another controller (/showthread.php?tid=33077) |
Call one controller from another controller - El Forum - 08-14-2010 [eluser]Unknown[/eluser] Sorry if this is a n00b question but I'm having a hard time wrapping my head around this... I have a site controller, this is responsible for gathering required data and loading views (Queries are hard coded while I'm testing): Code: class Site extends Controller { I also have a user controller which manages logging in etc. Code: class User extends Controller { Where the stars are I want to load the user_view, but as this view relies on certain data being passed to it, I want to load it by first calling Site->userView(). How do I achieve this? Or am I not understanding MVC properly? Call one controller from another controller - El Forum - 08-15-2010 [eluser]WanWizard[/eluser] After validating the login, store the logged-in state in the session, and use redirect to load the site controller. Call one controller from another controller - El Forum - 08-15-2010 [eluser]Prophet[/eluser] Can't User just load image_model? I wouldn't be too concerned with code repetition, especially simple stuff like loading views. Code: class User extends Controller { Edit: If you really want to call Site->userView() from User, just have User extend Site (since Site sounds like it would have some generic methods that will be useful to many controllers throughout the site?) |