Welcome Guest, Not a member yet? Register   Sign In
Automatically generate active class on links
#1

[eluser]rebellion[/eluser]
I use the URI class and URL Helper all the time to generate URLs, but every now and then I find myself in a position where I need to set a class on active links.

Now I solve it like this:

Code:
<?=anchor('page', 'My page', ($this->uri->segment(1)=='page')?array('class'=>'active'):'')?>

But is there a way to solve this without have to check alle the URI segments all the time? It would've been nice if CI's anchor function could automatically generate an active class for my links.




Theme © iAndrew 2016 - Forum software by © MyBB