Skip to main content

Drupal themeing : Adding active class to the Drupal primary links

An article from ComputerMinds - Building with Drupal in the UK since 2005
29th Jan 2008

Mike Dixon

Senior Mind
Mike Dixon
Hey, you seem to look at this article a lot! Why not Bookmark this article so you can find it easily in the future?

This little snippet lives in your phptemplate_variables function and will set a useful 'active' class alongside the not so useful menuid-active class which Drupal assigns to the active primary links


foreach($vars['primary_links'] as $key=>$link){
   if (strpos($key,'-active')){
      $vars['primary_links'][$key]['attributes']['class']='active';
   }
}

Hi, thanks for reading

ComputerMinds are the UK’s Drupal specialists with offices in Bristol and Coventry. We offer a range of Drupal services including Consultancy, Development, Training and Support. Whatever your Drupal problem, we can help.