[eluser]Mr. Pickle[/eluser]
Of course you can really make it easy by creating a helper function that does the job so you don't have to repeat the if statements all the time.
Just a rough idea:
helper, e.g. /helpers/MY_navigation_helper.php:
Code:
function get_nav_class($slug)
{
$CI =& get_instance(); // get instance of CI when putting this code in a helper
if($CI->uri->segment('1') == $slug)
{
$class = 'active';
}
else
{
$class = '';
}
return $class;
}
And then in the view file:
Code:
<? // activate the url helper to make anchor() available ?>
<ul>
<li class="<?=get_nav_class('alfa');?>">
<a href="<?=anchor('alfa');?>" title="Alfa">Alfa</a>
</li>
<li class="<?=get_nav_class('beta');?>">
<a href="<?=anchor('beta');?>" title="Beta">Beta</a>
</li>
<li class="<?=get_nav_class('gamma');?>">
<a href="<?=anchor('gamma');?>" title="Gamma">Beta</a>
</li>
</ul>