Theme a custom menu with theme_menu_tree()

∥☆過路亽.° 提交于 2019-12-21 21:21:26

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/6774398/theme-a-custom-menu-with-theme-menu-tree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!