I want to display the active item in my primary menu with a different color...so if im on a blog page the 'blog' menu item is highlighted...or if im on the contact page the 'contact' menu item is highlighted.

Is there a module that will do this, and if not what do i need to do to set an 'active' tag on the relevant menu item?

Comments

pobster’s picture

Learn about css... When a menu item is active, its gains a class called... "active"... Just style this in another colour.

Pobster

ltwinner’s picture

I know css and about the active tag. The problem is placing the active tag on an element based on the url of the page...For example on ?q=blog or ?q=blog/3 I want to set the blog menu item in the primary links to be active. And I'm wondering how people do this with drupal as it seems like fairly basic functionality to have.

dunkoh’s picture

if I'm not mistaken, drupal should handle placing the active class on the menu item for you, based on the page/path you're at.

Such as <li class="menu-97 active">

pobster’s picture

You're not mistaken, that's quite correct - seems the poster didn't actually look at what they're already receiving...

Pobster

ltwinner’s picture

hmmm, it's weird, drupal isn't setting an active tag on my primary menu items. It is on the navigation menu but for some reason not on the primary menu, gonna have to have a closer look at whats happening.

pobster’s picture

Mine do...

<li class="menu-3327 active-trail first last active">

This can be dependent on your theme though? These sorts of things can be overwritten in the themes template.php file. You are using proper Primary Menus BTW right? And not just manual links in your header...

Take a look at /admin/build/menu/settings and see where your primary and secondary menus are pointing at.

Pobster

ltwinner’s picture

ok cool, i looked at /admin/build/menu/settings and saw I had the menu items pointing to full urls such as http:/localhost/drupal/q=videos. When I changed it to simply point to 'videos' it sets the active tag. Cheers.