![]() |
A controller function can load another controllers?? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: A controller function can load another controllers?? (/showthread.php?tid=35296) |
A controller function can load another controllers?? - El Forum - 10-25-2010 [eluser]atoleon[/eluser] Hi Can i load a controller like i load a view? A controller function can load another controllers?? - El Forum - 10-25-2010 [eluser]WanWizard[/eluser] In standard CI, no, you can't. You can with a Modular solution, like Modular CI. A controller function can load another controllers?? - El Forum - 10-25-2010 [eluser]ShoKatoo[/eluser] [quote author="atoleon" date="1288037498"]Hi Can i load a controller like i load a view?[/quote] Please give an example... Is it something like calling a function declared in controller A from controller B? If that is so you can do this: Controller A Code: <?php Code: <?php You can now call function test_function() like http://localhost/contb/test_function even if you have no test_function() in Contb controller. The Contb controller extends the Conta controller inheriting all its function/methods. Have Phun! ![]() A controller function can load another controllers?? - El Forum - 10-25-2010 [eluser]WanWizard[/eluser] That's not one controller calling another, that is extending a class. Totally different concept. A controller function can load another controllers?? - El Forum - 10-25-2010 [eluser]ShoKatoo[/eluser] [quote author="ShoKatoo" date="1288045763"][...] The Contb controller extends the Conta controller inheriting all its function/methods.[...][/quote] Exactly what I said ![]() A controller function can load another controllers?? - El Forum - 10-25-2010 [eluser]tonanbarbarian[/eluser] if you find you have code in one controller that you would like to access from another controller then you probably need to move that common code into a library and then call the library from each controller |