Welcome Guest, Not a member yet? Register   Sign In
Codeigniter $data var for each view template
#1

[eluser]jcjc[/eluser]
I'm passing $data into a view on each page and have an autoload in place. Before the view I have the following:

Code:
$data['category'] = $this->productModel->listCategories();

I'm trying to find a way where I don't have to have this on each page view controller. I've tried placing the code inside the header.php template but I get undefined variable category.

Inside the header template I have:

Code:
<?php foreach ($category as $cat) : ?>
          <li><a href="/products/&lt;?php echo url_title($cat-&gt;ProductCategory, '-', TRUE); ?&gt;">&lt;?php echo $cat->ProductCategory; ?&gt;</a></li>
        &lt;?php endforeach; ?&gt;

Totally stumped!

In short, I need it to run on every page as it's in the header.


Messages In This Thread
Codeigniter $data var for each view template - by El Forum - 04-04-2014, 12:31 PM
Codeigniter $data var for each view template - by El Forum - 04-04-2014, 01:53 PM
Codeigniter $data var for each view template - by El Forum - 04-04-2014, 02:53 PM
Codeigniter $data var for each view template - by El Forum - 04-05-2014, 02:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB