Call another Controller's function - 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 another Controller's function (/showthread.php?tid=8521) |
Call another Controller's function - El Forum - 05-20-2008 [eluser]Unknown[/eluser] Hi, How do I call another Controller's function Ex. class Controller1 extends Controller { function test1() {} } class Controller2 extends Controller { function test2() { How can I call test1() in here considering that they are in 2 diff. controllers? } } Thanks, Michael Louie Loria Call another Controller's function - El Forum - 05-20-2008 [eluser]sikkle[/eluser] Humm if you need much method on two controller, think about library or helper, or maybe modular extention stuff. Take time to read user guide and forum a bit you'll save tons of hours. see ya around. Call another Controller's function - El Forum - 05-20-2008 [eluser]gtech[/eluser] seriously search the forums, when I am stuck I search the forums and usually someones already asked the question... scroll down 23 posts you will find someones asked this question today already . as sikkle suggests the answer is don't call across controllers, it goes against MVC design. 1)create a base controller with common functionality and then extend it (inherit). 2)create a library / helper function and call the function from both controllers. 3)move common logic into the model. good luck! |