I know that using hook_menu_link I can add classes to the <li>
tags but I need to add a class to the <a>
tags within the <li>
of a menu. I've looked and can't find a way.
Any ideas?
I know that using hook_menu_link I can add classes to the <li>
tags but I need to add a class to the <a>
tags within the <li>
of a menu. I've looked and can't find a way.
Any ideas?
You can do it from hook_menu_link
. You want to access the $vars['element']['#localized_options']['attributes']['class']
Something like this
$element = $vars['element'];
$element['#localized_options']['attributes']['class'][] = 'your-class';
$output = l($link_text, $element['#href'], $element['#localized_options']);
Then return the $output in the <li>
. Be sure to account for $vars['element']['#below']
if you have a sub-menu.