php - CodeIgniter: How to match current_url against views url (to construct a nav) -


in order apply active class current item in navigation menu. need check if link equal url

i trying this:

<ul class="nav">     <li class="<?php if(uri_string(current_url()) == base_url() || uri_string(current_url()) == '') echo 'active'; ?>">          <a href="<?php echo base_url() ?>">home</a>     </li>     <li class="<?php if(uri_string(current_url()) == base_url('news/create/')) echo 'active'; ?>">         <a href="<?php echo base_url('news/create/') ?>">+ new</a>     </li> </ul> 

wich seems work fine home

but in news/create won't ever equal....

it compares news/create (uri_string(current_url()) /news/create (base_url('news/create'))

so.. what's the way go issue?

as said, clean , simple solution:

if($this->uri->uri_string() == 'news/create'){ ... 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -