Welcome Guest, Not a member yet? Register   Sign In
Best practice to including sidebar on some pages, but not all?
#4

[eluser]ELRafael[/eluser]
[quote author="lane4" date="1257561261"]Pass a variable named sidebar to your view:

Code:
// ...
$data['sidebar'] = 'mysidebar';
$this->load->view('page',$data);

In your page view:

Code:
<?php if ($sidebar) $this->load->view($sidebar); ?>

So you can tell your page views which sidebar to load, or not.[/quote]

be carefull with this.
if you don't set $data['sidebar'] in your controller, when you try to call a non-defined var in your view, maybe php shows a warning.

imo
In you page view
Code:
<?php echo (isset($sidebar)) ? $sidebar : ''; ?>


Messages In This Thread
Best practice to including sidebar on some pages, but not all? - by El Forum - 11-06-2009, 02:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB