Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Theme a custom menu with theme_menu_tree()

I'm trying to override a custom menu output in a block so that instead of

    <ul class="menu">...</ul>

I can get

    <select name="menu title">...</select>

In Drupal 6, I could use function theme_menu_tree($tree,$menu_name="") {...} but this doesn't work in Drupal 7 with function theme_menu_tree($variables) {...}.

I've tried theme_menu_tree__mymenu($variables) {...} with no success. How do I specify a unique menu in Drupal 7?

Thanks.

like image 729
solange Avatar asked Mar 13 '26 16:03

solange


1 Answers

I had the same problem with overriding and correct naming of the theme_menu_tree function for a specific menu name. What I found I suppose that the correct name of your function should be: YOUR_THEMENAME_menu_tree__YOUR_MENUNAME

The name of your menu could be taken from Administration » Structure » Menus pages. It seems to me that Drupal adds word "menu" before all of the new user menus. In my case I created a menu called "Testing menu" in a theme "Mytheme" and the name of the overriding function was: mytheme_menu_tree__menu_testing_menu

like image 132
chalda Avatar answered Mar 15 '26 08:03

chalda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!