![]() |
I have extended Controller, how to use a function in view files? - 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: I have extended Controller, how to use a function in view files? (/showthread.php?tid=10115) |
I have extended Controller, how to use a function in view files? - El Forum - 07-18-2008 [eluser]loathsome[/eluser] Hi there. I have extended the Controller class (with BaseController), and I have a custom _load function in that. When I do this: Code: class Dummy extends BaseController { Everything works as it should ![]() Code: <h2>Hello</h2> Though, that doesnt work. Thanks! I have extended Controller, how to use a function in view files? - El Forum - 07-18-2008 [eluser]sophistry[/eluser] the fast reply is that controllers are for handling http requests that come from the browser/user; they are not designed for handling calls from a view (or anywhere else for that matter). that is why they are called controllers. if you want to reuse code in the way you describe, make a plugin or helper or library. if you want to call controllers from other controllers (or embed controller calls in a view) you'll need to check out wiredesignz's "Modular Extensions" (I feel an eerie sense of deja vu) ;-) check the wiki - it's pretty easy to set up and you'll be calling controllers from views in just a few hours. cheers. I have extended Controller, how to use a function in view files? - El Forum - 07-18-2008 [eluser]loathsome[/eluser] Hah! Thanks again, sophistry! I also felt a slight deja vu when reading your post. Best. |