Answer the question
In order to leave comments, you need to log in
How to add class to menu links programmatically?
The task is simple. It is necessary to programmatically add a couple of classes to the "menuname" menu links.
Add to all links without exception.
I could do it on jquery, but why if there is Drupal.
I searched in theme_menu_link, but there you can do everything only in a link wrapper,
but you need with the link itself.
I spent half a day on this nonsense, I have no more strength. save)
Answer the question
In order to leave comments, you need to log in
function YOUR_MODULE_preprocess_menu_link(&$variables) {
$variables['element']['#attributes']['class'][] = 'your_class';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question