0

The following code allows me to print the secondary menu.

<?php print theme('links__system_secondary_menu', array('links' => $secondary_menu, 'attributes' => array('id' => 'secondary-menu', 'class' => 'menu nav navbar-nav secondary hidden-xs'))); ?>     

I get the following output.

<ul id="secondary-menu" class="menu nav navbar-nav secondary hidden-xs">
<li class="menu-6734 first"><a href="/" title="">link 1</a></li>
<li class="menu-6735 first"><a href="/" title="">link 2</a></li>
<li class="menu-6736 first"><a href="/" title="">link 3</a></li>
</ul>

Now, I need to add dropdown to the last menu item but I have no idea how to do it. Any guidance much appreciated!

1 Answer 1

0

You can theme secondary menu using THEME_links__system_secondary_menu like the following:

function THEME_links__system_secondary_menu(&$vars) {
  // Get links:
  $links = $vars['links'];
  // Get the index of last menu item.
  end($links);
  $last_ele_index = key($links);
  // Here do your logic by change ...
  // $vars['links']['$last_ele_index'];
}
2
  • Thank you very much, this will do it for me!
    – Efe
    Dec 29, 2019 at 21:44
  • Welcome, glad that helped!
    – berramou
    Dec 29, 2019 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.