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
Post a Comment