Adding an "active" CSS class to the <li> element in menus
I seem to keep finding different ways to add an "active" CSS class to <li> elements in menus. I must have been a bit dense, but it took me a little while to figure that menus are displayed using different methods, hence they need different ways to add in the extra class. Here are the methods:
- Using theme_menu_tree e.g. Navigation menu, any menu shown via a block.
Interesting tidbit here: these menus can have parts of them expanded using the option on the edit menu item page. - Using theme_links e.g. primary and secondary menus when shown via theme('links', $primary_links...) in page.tpl.php.
These menus will never be expanded using that menu option
OK, got that?? Hehe, don't worry, I'll show you how to fix both methods.
Post new comment