Hi all, I'm stuck, because with drupal 6 seems like menus are no longer single-styled (with drupal 5 I had ".menu-X-Y-Z" classes) but they only have ".leaf" and ".first" and ".last" classes, which is not enough.
How can I bypass this problem?
The solution I'm using is using a custom block with an html menu inside, but this solution can't have "active" classes as well :(
1) can I reintroduce particular classes for the menus?
2) can I create something that mimic this behaviour with php within the theme?? (how?)

Thank for the help!

Comments

ThePeach’s picture

Please help :(

Jeff Burnz’s picture

Create a new block and use this snippet (set input format to PHP naturally).

<?php
$my_menu = theme('links',menu_navigation_links('menu-name-of-my-menu'),array('class' => 'links', 'id' => 'my-menu'));
print $$my_menu;
?>

Replace menu-name-of-my-menu with the actual name of your menu - to find this go to the menu admin page (admin/build/menu) and hover over the link to your menu, its the last bit of the URL in the status bar (its always called something like menu-xxx).

You should probably replace the id with your own CSS selector and to get the menu to display vertically you can use display: block on the li.

ThePeach’s picture

thanks jmburnz
I've found a similar way to do that: I added this snippet of php code to page.tpl.php:

  foreach ($primary_links as $key=>$value)
    $primary_links[$key]['class'] = 'menu-'.$key;
  print theme('links', $primary_links, array('class' => 'primary-links'));

in your solutions I didn't get if I need to add the actual menu block after the block with the php snippet you posted

Jeff Burnz’s picture

The first two lines appear to be doing nothing, all you need to print the primary menu is:

<?php print theme('links', $primary_links, array('class' => 'primary-links')); ?>

Your original question was not clear if you were asking about primary links or any menu, I assumed it was any menu, since primary links do this anyway.

With the solution I posted you just build a menu and add the snippet where-ever you like, in a block, page.tpl.php etc, this works with normal menus, but it's not really meant for primary or secondary links - all you need is to run them throught the theme_links function and viola (as above).

ThePeach’s picture

you're right: the first two lines did nothing :-( I thought they were needed...
and yes: I was referring to any menu, using primary menu is just a mere convenience.
I'm trying your solution then :)