Creating a menu |
[eluser]giovannidc[/eluser]
I've create a menu that looks similar to this: Code: <ul class="primary-menu"> Any ideas on how I could add the class="active" to the desired list item depending on the controller being called? Thanks in advance!
[eluser]Philo01[/eluser]
If you use page names in the url you can use the URI class to add the active state: Code: <ul class="primary-menu"> Works easier if your pages come from a database so you can just add this to the loop. -- URI Class http://ellislab.com/codeigniter/user-gui...s/uri.html
[eluser]louisl[/eluser]
Pretty much what Philo01 said, but I use a little helper function then use it all over the place, I got a bunch of other useful funcs in there too. Code: <li<?php echo class_selected($this->uri->segment(1), 'menu-item'); ?>>Menu item</li>
[eluser]CroNiX[/eluser]
You can use: $RTR->get_class() and $RTR->get_method() to get the, well, current class and method called ![]()
[eluser]giovannidc[/eluser]
Thanks guys for responding so fast and providing helpful suggestions, I made use of Philo01's suggestion :coolsmile: |
Welcome Guest, Not a member yet? Register Sign In |