call function beetween controllers - 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 function beetween controllers (/showthread.php?tid=57413) |
call function beetween controllers - El Forum - 03-13-2013 [eluser]GabrieleMartino[/eluser] Hi, is it possible to execute a function beetween controllers without making a redirect? Thanks call function beetween controllers - El Forum - 03-13-2013 [eluser]TheFuzzy0ne[/eluser] Can you be more specific? If you need shared functionality, it's probably best to put it into a library or helper, or to create a base controller which has the functionality you require, and extend that from the other controllers that require it. call function beetween controllers - El Forum - 03-13-2013 [eluser]Seto El Kahfi[/eluser] [quote author="GabrieleMartino" date="1363162965"]Hi, is it possible to execute a function beetween controllers without making a redirect? Thanks[/quote] Do you mean making instance from another controller? As long as I know, CI restrict you from do that method. Maybe I'm wrong. call function beetween controllers - El Forum - 03-13-2013 [eluser]GabrieleMartino[/eluser] [quote author="TheFuzzy0ne" date="1363163937"]Can you be more specific? If you need shared functionality, it's probably best to put it into a library or helper, or to create a base controller which has the functionality you require, and extend that from the other controllers that require it.[/quote] Of course, thanks. I have in my pages controller the following function Code: public function pick_up($user_id){ And in my chat controller Code: public function enter_living_room($language){ call function beetween controllers - El Forum - 03-13-2013 [eluser]TheFuzzy0ne[/eluser] Would it not make more sense to make a library, and then manipulate that from your controllers? call function beetween controllers - El Forum - 03-13-2013 [eluser]Otemu[/eluser] [quote author="TheFuzzy0ne" date="1363168677"]Would it not make more sense to make a library, and then manipulate that from your controllers?[/quote] As the TheFuzzy0ne said best to use a library then you could use something like this: Code: $this->yourLibrary->yourFunction('do something’) |