Do I miss something or is it impossible to theme the link anchor HTML element
<ul class="main-menu"><li><a href="" class="put something in here"></li></ul> for a targeted menu on the theming level (theme functions)?
We can theme the
<li> elements and the menu block elements with HOOK_menu_link_MENU_NAME(). Thanks to David Thomas for pointing that out to me. But I had no luck with targeting the nested anchors itself. The Devel array output and the drupal.org docs only brought me to
theme_link(), and others, but I can't see an opportunity here to elegantly incept dynamic values for css classes on the anchor element?
I would like to add style class attributes to the
<a> element in ul > li of a given menu (not of all menus, thats what
nested css targeting by altering the upper element is not an option here, since the required css class is level sensitive and should NOT be applied to the upper html element.
And yes, I know the menu_attributes module. It's an awesome module I use very often. But the approach is different. I don't want to change the menu link data in the DB, but the output only.
There is an issue for the
theme_links()function on drupal.org mentioning some trouble with its scope and how it works: https://drupal.org/node/588148
theme_links(): Returns HTML for a set of links. => theme_links($variables) https://drupal.org/node/588148 => theme_links() is not really themeable [#588148] => Drupal core, theme system, normal, needs work, 49 comments, 1 IRC mention
Another option would be to add
<span>elements inside the anchor elements. I already did this for node objects but I don't know if this is possible here and if this is the right way to do it.
Edit: Here are two questions - 1 - 2 - on stackexchange I read thru' atm, since there are near issues discussed. Maybe it will enlighten me soon ... (Thanks to Clive, who has pointed me to the second one.)