Hello - this pertains to CI but i guess the issue is similar for all frameworks.
I am using an authentication library (tank-auth) to handle login/registration etc.
- so i already have an auth controller ( say Controller A) - with a method 'login' - that calls the view 'login-form'.
This is working perfectly well. So far so good
However now i need to show the login form on the top of each page (say on home page) - this home page is controlled by a different controller - say Controller B.
Now how do i call the method in controller B (say the login method) from controller A ?
Code-Igniter: calling a controller within a controller
Moderator: General Moderators
Re: Code-Igniter: calling a controller within a controller
some quick search seems to be pointing out in the direction of modular development (HMVC) - but i am not sure how to apply this to CI.
Isnt' MVC supposed to ease out development ? so wht is the fuss of it not being modular and why cant it handle two or more modules display per page ?
Isnt' MVC supposed to ease out development ? so wht is the fuss of it not being modular and why cant it handle two or more modules display per page ?
- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: Code-Igniter: calling a controller within a controller
Yeah this is something that, for instance, Kohana and Fuel are both set up for. It's been a while since I used CI and this approach may no longer work/may be greeted by cries of anguish because it's some kind of bad practice, but I seem to remember trying to do something similar ages ago with CI. I simply used a wrapper function that instantiated the controller class and called the relevant action, I can't remember if it used output buffering or not, I don't think it was necessary though.
Re: Code-Igniter: calling a controller within a controller
I eventually did something similar using wrapper of sorts.
and this is one reason why I later moved to YII framework - (widgets and modules are inherently supported) - though i am still trying to figure out YII in its entirety.
and this is one reason why I later moved to YII framework - (widgets and modules are inherently supported) - though i am still trying to figure out YII in its entirety.