Controller inside a view - 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: Controller inside a view (/showthread.php?tid=28604) |
Controller inside a view - El Forum - 03-16-2010 [eluser]Unknown[/eluser] Hi, I'm developing some app and I'm trying to use a template-like method, for example, in the left side I'll load all users in my app and I want to do it in a view but that view needs a controller to load everyone, my question is: How can I load a controller in a view? if this is possible, if not how can I do this. Thanks in advance :-) Controller inside a view - El Forum - 03-16-2010 [eluser]seanloving[/eluser] HMVC allows me to load controllers in my views. For example, in my views/header.php file... Code: echo modules::run('pages/navigation/widget', 'header'); Controller inside a view - El Forum - 03-16-2010 [eluser]mattpointblank[/eluser] You have it backwards. Use a controller to get your data, then send it to your view(s). Controller inside a view - El Forum - 03-16-2010 [eluser]Zeeshan Rasool[/eluser] In CI, you can not call controller directly in view. You need to perform all your actions inside controller and then pass your result to view. In your current scenario, you need a parser method. See parser help for this. You can parse your left panel and just pass this parsed array to final view. |