Just wondering if anyone has pulled this off.

The only example I've found (just searching around) was this:

http://www.cssgirl.com/resources/2008/06/22/how-to-use-css-sprites-with-...

and it didn't involve drupal at all.

So if I used her example, I'd have to get Drupal to spit out distinct class names on the "a" tags.

So, first, can this be done without classnames on the "a" tags? (Like a default, drupal menu spits out?)

And, if not, how does one get drupal to put, say, the $mid for each "a"'s class? (Or any other distinct class name?)

Any help is much appreciated.

Thanks.

Comments

rpalomo’s picture

The menu system in D6, i think D5 too, uses theme_menu_tree, theme_menu_item and theme_menu_item_link to theme the menus via hooks

You could override hooks in your theme to spit the special tag with all your class info.
the $link[menu_name] contains the menu name that you can use to identify the menu you want. Consider that this hooks are called for ALL menus. so make sure you filter who you want to change. And set your class in an array $options['class'] and use it to call the l() function.

if ($link['menu_name']=='myspecialmenu'){
$options=array();
$options['class']='my_a_class';
return l($link['title'], $link['href'], $options);
}
else
theme_menu_item( put all arguments here );

http://api.drupal.org/api/function/theme_menu_item_link/6

FYI: i have a small in the works module that allows you to set up a picture menu. It works, but Its not done, I can share if you have some time.

aaronelborg’s picture

I'd be totally interested in your module, rpalomo.

Man, i need to set an rss feed up on this thing........

I would've missed this, had I not just checked in.

Grazi!

rpalomo’s picture

Actually there is an imagemenu module already done you can find in the modules.

aaronelborg’s picture

....

aaronelborg’s picture

Been meaning to post this for some time........just getting around to it.

You want classes on your a tags?

You got 'em!

function phptemplate_menu_item_link($link) {
  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();
  }
  if (empty($link['localized_options']['attributes']['class'])) {
    $link['localized_options']['attributes']['class'] = 'menu-'. $link['mlid'];
  }
  else {
    $link['localized_options']['attributes']['class'] .= ' menu-'. $link['mlid'];
  }
  return l($link['title'], $link['href'], $link['localized_options']);
}