I'm a Drupal newbie and need a spot of help with menu item HTML.
I'm using several Menus on a site and I need to generate different HTML for them.

In my custom theme template.php file, I can override theme_menu_item(). Tried that and it's working. However, it changes the output HTML for all my menus. e.g. if I add

function mytheme_menu_item(...) {
  ...
  $sep = "<span class="sep"> | </span>";
  return '<li class="'. $class .'">'. $link . $menu . $sep ."</li>\n";
}

Then I get the separator added to the html of every menu item. I want to conditionally change the HTML based on some value I pass in (it might be the region the menu is in, or how menu items it has or whatever.) I might want separator HTML on one set of menu items, or add other html elements on another, or add id or title attributes to the li of a different menu.

Anyone recommend a strategy for this?

Thanks,
Mike

Comments

WorldFallz’s picture

You need to add the logic to check for different menu item conditions right into the function itself. For an example, see http://drupalcontrib.org/api/function/dhtml_menu_theme_menu_item