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

[eluser]jcjc[/eluser]
Not multiple views, I have a header.php within a layout folder. Inside the header.php is the following code:

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;

Inside my controller I have the following code:

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


Now my issue is that I have multiple controllers that need to call the code in the second block. for the moment I would have to call this code inside every controller I create causing bloat. Is there a way in which I can have the code above "echo'd" out on the header.php without having to pass $data via each controller?


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