how access a function in 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: how access a function in another controller (/showthread.php?tid=13063) |
how access a function in another controller - El Forum - 11-09-2008 [eluser]minhbu[/eluser] in controller B and i want to access a function in controller A. How do it ? how access a function in another controller - El Forum - 11-10-2008 [eluser]dcunited08[/eluser] Either the function has to be static or you have to use [url="http://codeigniter.com/wiki/Modular_Extensions_-_HMVC"]Modular Extensions HMVC[/url] or [url="http://code.google.com/p/incendiary/downloads/detail?name=wick-0.80.zip"]Wick[/url], what are you planning to do with it? how access a function in another controller - El Forum - 11-10-2008 [eluser]Xeoncross[/eluser] My guess is that "the function" should be in a library/model instead of a controller... how access a function in another controller - El Forum - 11-10-2008 [eluser]m4rw3r[/eluser] You can also make it a static method, and then include the controller file with a normal require and then call Controllername::method(). how access a function in another controller - El Forum - 11-10-2008 [eluser]minhbu[/eluser] i will try to use static method. Thank you, ahhhhhh who have another way ? how access a function in another controller - El Forum - 11-11-2008 [eluser]Unknown[/eluser] The short is that there really isn't an easy way without either passing the first controller to the second as some type of parameter, using a static method, or making some form of Borg/Singleton structure. Depending on context, the Singleton does seem to be a rather popular feature of the CodeIgniter base anyway... how access a function in another controller - El Forum - 11-11-2008 [eluser]dcunited08[/eluser] [quote author="minhbu" date="1226387721"]i will try to use static method. Thank you, ahhhhhh who have another way ?[/quote] Can you please let us know what you are attempting to do? |