[eluser]Met[/eluser]
hola
Must be missing something.
I quote the reference (
http://www.williamsconcepts.com/ci/codei...rence.html )
Quote:"My template uses other variables that aren't necessarily regions. How do I supply those within Template?"
You most likely will use variables in your main template that aren't content regions. For example, you might have a $body_id variable that you apply to the <body> element that you use in your CSS to apply styles to specific pages. This certainly could be a region, but it wouldn't quite fit the metaphor.
To supply these variables to your master template, use CodeIgniter's $this->load->vars() mechanism.
my code:
Code:
<?php
class Site extends Controller {
function __construct()
{
parent::__construct();
$this->load->library('template');
}
function index()
{
$this->template->write('title', 'My title');
$data['active']='home';
// i want to pass the template $active so the appropriate navigation link gets the "active" class appended to it.
// now i guess I'm missing something:
$this->load->vars($data);
$this->template->write_view('content', 'home/index');
$this->template->render();
}
// my master template looks like (code highlighting is broked, its not a parse error)
<body>
<ul id="nav">
<li class="home <?php if($active=='home') echo 'active';?>">
<?=anchor(base_url(), 'Home');?>
</li>
</ul>
<!-- etc -->
makes sense to me, but i'm clearly missing something. $active doesn't appear to be being set.
thanks !