Wondering how could I have classes for each level, as I would like to make bold second and plain text third level, but now it is all the same and there is not class for this. Ofcoures this would have to be automaticly for levels, not that you need to add manaully class for each menu item.

Comments

Marko B’s picture

I am talking about the menu block that has few levels in itself, as each block has a starting level css.

Marko B’s picture

No comments on this? So strange request? Does anybody do CSS here and themes their menus to look nice, readable and user friendly?

davidd07’s picture

You could install the Menu Attributes module OR you can theme_menu_link function.

Marko B’s picture

I know I can, but then I need to manually add some CSS to blocks and then each time there is new menu item, it has to have some new css, it is just not good solution. We build CMS so layman can enter data in it, and I really don't expect to expain to them that they need to add some attributes to menu?! Wouldn't that make sense to have level classes in this otherwise great module?

Marko B’s picture

I recommend this solution http://drupaldump.com/adding-menu-level-value-css-class
and not to use menu attributes, as that is not practical solution.

gmclelland’s picture

@Marko B - The problem with that solution is that it gives you the menu levels, but they aren't relative to what is displayed. If I'm showing a deeply nested the menu in the sidebar, the first level will show as level-4 instead of level-1. That prevents me from styling only the first level menu items.

I would love to hear other peoples solutions to this? There is also #1967912: Reset depth attribute on menu items, but I couldn't get the patch to work correctly.

modulist’s picture

The solutions is quite simple: you can use CSS selectors as follows to have different styles for different menu levels:

ul.menu for the entire menu tree
ul.menu li for top level items and below
ul.menu li li for second level items
ul.menu li li li for third level items
and so forth

This technique can be use for Drupal menus in core and for nice menus as well