CodeIgniter Forums
hmvc partial views - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: hmvc partial views (/showthread.php?tid=40719)



hmvc partial views - El Forum - 04-16-2011

[eluser]RJ[/eluser]
I have a dashboard that contains several partials, the only way I found to load these partials in the controller is:

The display controller:
Code:
private function _dashboard()
        {
                $glimpse = $this->load->module('glimpse');
                
                $this->template
                        ->set('glimpse', $glimpse->load())
                        ->build('dashboard');
        }

Then in glimpse I have:
Code:
function load()
    {                
        return $this->load->view('g_profile', true);
    }

I have to do the same thing to display a simple login box, but I don't like having to setup a separate method in the module controller to return these views. I also don't want to do Modules::run() in the view (logic should be in controller imho).

What method do you use to load partial views from one module to the next?


hmvc partial views - El Forum - 07-17-2011

[eluser]seanloving[/eluser]
I think you can call modules::run directly from your controller like this (untested):

Code:
private function _dashboard()
        {
                $glimpse = $this->load->module('glimpse');
                $load = modules::run('glimpse/load');
                
                $this->template
                        ->set('glimpse', $load)
                        ->build('dashboard');
        }

-seanloving


hmvc partial views - El Forum - 07-17-2011

[eluser]RJ[/eluser]
I'll give it a whirl. Thank you for commenting on this old post :-)