Posted By

bindirtit on 05/16/12


Tagged

php


Versions (?)

Code Igniter: Highlight current page in menu


 / Published in: PHP
 

test create new snippet

  1. <ul>
  2. <li class="<?=($this->uri->segment(1)==='alfa')?'active':''?>"><a href="alfa/index" title="Alfa">Alfa</a></li>
  3. <li class="<?=($this->uri->segment(1)==='beta')?'active':''?>"><a href="beta/index" title="Beta">Beta</a></li>
  4. </ul>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: luxwan13 on February 28, 2013

I think you should add strtolower() for the $this->uri->segment(1) part. In case the uri becomes "ALFA/index", your highlighting will otherwise become broken.

You need to login to post a comment.