I have seen several examples for adding ID's to menu links in drupal 5. I am unable to find any help tring to do the same thing for drupal 6.

How do i add Id's to menu links in drupal 6?

Comments

roopletheme’s picture

I used this code in template.php to add a class named item-menu_title to menus.

function phptemplate_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
  $class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
  if (!empty($extra_class)) {
    $class .= ' '. $extra_class;
  }
  if ($in_active_trail) {
    $class .= ' active-trail';
  }
  $class .= ' item-'. strtolower(str_replace(' ', '_', strip_tags($link)));
  return '<li class="'. $class .'">'. $link . $menu ."</li>\n";
}

Just a variation on the original Nick Lewis approach.

mconway’s picture

Thanks so much, Exactly what I was looking for.

spede’s picture

Oh no, this is something that I've really been searching for, but for some reason it doesn't seem to work on my site. I cleared the cache on my D6 site, but no...? Argh.

EDIT: Wait a minute, now it works! Well, whatever the reason in the first place, this is great!

UNarmed’s picture

It works great, how would i add this to my admin menu aswell tho??