Welcome Guest, Not a member yet? Register   Sign In
Difficulty understanding how to code up a webpage
#4

[eluser]Carlton[/eluser]
Thanks for the responses, they have helped massively! :-)

I have one question though...I like the two methods outlined below especially the first...however if I have two controllers (maybe 'News' and 'Blog') is it possible to make the $sidebar variable accessible to both without the need to define a data aray for each controller? I thought by using $this->load->vars this would work allowing sidebar to be accessible to all Controllers and view...or is it only views called by the controller in which the variables were loaded?

Using the second method avoids this as it is the view requesting the data but I would prefer to pass data to the view rather than the view request it.
Code:
// METHOD 1
<html><head></head><body>
<?=header;?>
<?=sidebar;?>
<?=content;?>
<?=footer;?>
</body></html>

// METHOD 2
<html><head></head><body>
<?=$this->load->view('header');?>
<?=$this->load->view('sidebar');?>
<?=content;?>
<?=$this->load->view('footer');?>
</body></html>

// Controller e.g. Blog
function index ()
{
    $data = array(
        'page_title' => 'Blog',
        'sidebar' => $this->load->view('sidebar_view', null, true)
    );

    $this->load->vars($data);
    $this->load->view('master_view');
}


Messages In This Thread
Difficulty understanding how to code up a webpage - by El Forum - 08-08-2007, 10:23 AM
Difficulty understanding how to code up a webpage - by El Forum - 08-08-2007, 10:50 AM
Difficulty understanding how to code up a webpage - by El Forum - 08-08-2007, 12:52 PM
Difficulty understanding how to code up a webpage - by El Forum - 08-09-2007, 04:36 AM
Difficulty understanding how to code up a webpage - by El Forum - 08-09-2007, 09:04 AM
Difficulty understanding how to code up a webpage - by El Forum - 08-11-2007, 12:59 PM
Difficulty understanding how to code up a webpage - by El Forum - 08-11-2007, 07:07 PM
Difficulty understanding how to code up a webpage - by El Forum - 08-12-2007, 02:23 AM
Difficulty understanding how to code up a webpage - by El Forum - 08-12-2007, 02:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB