Skip to main content
edited title
Link
eye-wonder
  • 503
  • 4
  • 14

Add a span and class to menu items that has children

Title edit
Link
eye-wonder
  • 503
  • 4
  • 14

Add class "hasChildren"a span to li elements Using Menu Block Modulemenu items that has children

added 574 characters in body
Source Link
eye-wonder
  • 503
  • 4
  • 14

I'm customizing the main menu using the Menu Block Module. I need to set a class for all li elements that has children regardless of level. I might need to add a span inside the a-tags as well. Is it possible to do this in the template.php or do I need to alter module files. I would preffere not to edit module files if possible.

Like:

<li class="expanded menu-mlid-871 has-children">
   <a href="...">Menu item name<span class"test"><class="test"></span></a>
   <ul> <!-- (children items) --> <ul>
</li>

Is this doable with some:

function theme_menu_link(array $variables) { ...?... }

[edit]

Menu items with no children has the class="leaf". It should be possible to style the menu items li (has children) and then cancel the rule-set for the class li.leaf (has no children). The span can be added by using some li::after rule-set and removed with eg li.leaf::after {display:none;}

In this way it can be solved with CSS only. The problem is I need to use the <span class="test"></span> for a click event. So at least I need a real span inside the li a witch is not a "leaf".

Anyone who can help me with a theme functions for this?

I'm customizing the main menu using the Menu Block Module. I need to set a class for all li elements that has children regardless of level. I might need to add a span inside the a-tags as well. Is it possible to do this in the template.php or do I need to alter module files. I would preffere not to edit module files if possible.

Like:

<li class="expanded menu-mlid-871 has-children">
   <a href="...">Menu item name<span class"test"></span></a>
   <ul> <!-- (children items) --> <ul>
</li>

Is this doable with some:

function theme_menu_link(array $variables) { ...?... }

I'm customizing the main menu using the Menu Block Module. I need to set a class for all li elements that has children regardless of level. I might need to add a span inside the a-tags as well. Is it possible to do this in the template.php or do I need to alter module files. I would preffere not to edit module files if possible.

Like:

<li class="expanded menu-mlid-871 has-children">
   <a href="...">Menu item name<span class="test"></span></a>
   <ul> <!-- (children items) --> <ul>
</li>

Is this doable with some:

function theme_menu_link(array $variables) { ...?... }

[edit]

Menu items with no children has the class="leaf". It should be possible to style the menu items li (has children) and then cancel the rule-set for the class li.leaf (has no children). The span can be added by using some li::after rule-set and removed with eg li.leaf::after {display:none;}

In this way it can be solved with CSS only. The problem is I need to use the <span class="test"></span> for a click event. So at least I need a real span inside the li a witch is not a "leaf".

Anyone who can help me with a theme functions for this?

added 4 characters in body
Source Link
eye-wonder
  • 503
  • 4
  • 14
Loading
Source Link
eye-wonder
  • 503
  • 4
  • 14
Loading