I have a home controller with an index action that displays a set of featured products. However, the products are managed through a product controller including a proprietary model and views.
How do I access product information from within the index action in the home controller? Instancing product won’t work as the class isn’t loaded at runtime and CodeIgniter doesn’t provide a way to dynamically load controllers. Putting the product class into a library file doesn’t really work, either.
To be precise, I need the product views (filled with data processed by the product controller) inserted in the index view. I’m running CodeIgniter 2.0.2.
If you’re interested, there’s a well-established package out there that you can add to your Codeigniter project that will handle this:
https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/
OK, so the big change is that now you’d be using a modular structure – but to me this is desirable. I have used CI for about 3 years now, and can’t imagine life without Modular Extensions.
Now, here’s the part that deals with directly calling controllers for rendering view partials:
That’s all there is to it. I typically use this for loading little "widgets" like:
Typically I build a "widget" controller for each module and use it only for this purpose.