Search code examples
classmenudrupal-7

Get menu item class in Drupal 7


I´m trying to get menu items classes/IDs to be able to write a conditions for front-end.

I tried the following code :

$element['#attributes']['class']

But it's not showing me anything.

Can you please show me a way?


Solution

  • There is a nice little module to do this if you don't need to hard code them:

    https://www.drupal.org/project/menu_attributes