Welcome Guest, Not a member yet? Register   Sign In
Construct & destruct - quick question
#2

[eluser]TheFuzzy0ne[/eluser]
Loading a view in the desctructor is probably not the best place to do this. There are lots of topics on the forum pertaining to this problem. The solution is to create a main template file, which loads the header, navigation, footer and anything else, and also loads the content dynamically depending on the variable you pass to it.

Main template
Code:
<?php $this->load->view('header'); ?>
<?php $this->load->view('navigation'); ?>
<?php echo $content; ?>
<?php $this->load->view('footer'); ?>

Controller Method
Code:
function index()
{
    $this->load->vars(
        array
        (
            'content' => $this->load->view('some_view', null, TRUE),
            'another_var' => 'some_value',
        )
    );

    $this->load->view('main_template');
}

I hope this helps.

EDIT: Fixed a few syntax errors on my code.


Messages In This Thread
Construct & destruct - quick question - by El Forum - 06-29-2009, 07:28 AM
Construct & destruct - quick question - by El Forum - 06-29-2009, 07:36 AM
Construct & destruct - quick question - by El Forum - 06-29-2009, 07:38 AM
Construct & destruct - quick question - by El Forum - 06-29-2009, 07:47 AM
Construct & destruct - quick question - by El Forum - 06-29-2009, 08:01 AM
Construct & destruct - quick question - by El Forum - 06-29-2009, 08:48 AM
Construct & destruct - quick question - by El Forum - 06-29-2009, 08:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB