Welcome Guest, Not a member yet? Register   Sign In
Am I Loading this View wrong?
#5

[eluser]Oscar Dias[/eluser]
If your views inside /include aren't going to change, you can create a library that loads that for you. Something like this:
Code:
class Common {
    function show($view, $data = array())
    {
        // Get current CI Instance
        $CI = & get_instance();
                
        // Grabbing all the files associated with the current user
        $CI->load->model("membership_model");
        $q = $CI->membership_model->user_info();
        $data_topMembers['user_info'] = $q;

        // Load include views
        $CI->load->view('includes/header');
        $CI->load->view('includes/topMembers', $data_topMembers);
        $CI->load->view('includes/news');
        $CI->load->view($view, $data);
        $CI->load->view('includes/footer');
    }
}

Depending on your needs this might be a good solution. You can pass additional parameters, for example SEO information for your header view... Then in your controller you do:
Code:
$this->load->library('common');
$this->common->show($main_content);


Messages In This Thread
Am I Loading this View wrong? - by El Forum - 08-17-2012, 03:50 PM
Am I Loading this View wrong? - by El Forum - 08-17-2012, 04:00 PM
Am I Loading this View wrong? - by El Forum - 08-17-2012, 04:11 PM
Am I Loading this View wrong? - by El Forum - 08-17-2012, 04:16 PM
Am I Loading this View wrong? - by El Forum - 08-17-2012, 09:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB