1
1
|
I want to generate the html elements and their classes to fit my styling of the main menu.
I'm confused by all the near-possibilities offered in the api documentation and by looking at core themes etc. and still can't quite see what I have to do, or where I have to do it.
Presumably, in
[Update] So far I have discovered one way to place classes on the Main Menu's
This function goes into the file
|
||||||||
|
1
|
Override the twig file for the main menu by saving You can then modify the Twig macro used to generate the menu output. To get a class on the ul's to indicate level, you could do this:
You could do similar manipulations to the li's:
Just tack on
If you're a HTML/class name snob like myself you can also remove classes like so:
Which I did on the line above the |
||||
|
0
|
The way to get the main menu with items in all levels has been resolved in Drupal 8 - "Implement menu links as plugins", trying to build a menu tree To add class to ul and li, we got 3 options: A. Override menuTree service:
P.S: Not very sure, if you need to do these whole override for adding class. B. Override just tree build on theme layer:
C. Using Drupal.behaviors.MYTHEME in JavaScript (from https://www.drupal.org/project/gratis)
|