使用 theme_menu_tree() 为自定义菜单设置主题 [英] Theme a custom menu with theme_menu_tree()

查看:25
本文介绍了使用 theme_menu_tree() 为自定义菜单设置主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试覆盖块中的自定义菜单输出,而不是

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

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

我可以得到

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

在 Drupal 6 中,我可以使用函数 theme_menu_tree($tree,$menu_name="") {...} 但这在带有函数 theme_menu_tree($variables) {...}.

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) {...}.

我试过 theme_menu_tree__mymenu($variables) {...} 没有成功.如何在 Drupal 7 中指定唯一的菜单?

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

谢谢.

推荐答案

我在重写和正确命名特定菜单名称的 theme_menu_tree 函数时遇到了同样的问题.我发现我想你的函数的正确名称应该是:YOUR_THEMENAME_menu_tree__YOUR_MENUNAME

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

您的菜单名称可以取自管理 » 结构 » 菜单页面.在我看来,Drupal 在所有新用户菜单之前添加了菜单"一词.在我的例子中,我在主题Mytheme"中创建了一个名为Testing menu"的菜单,覆盖函数的名称是:mytheme_menu_tree__menu_testing_menu

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

这篇关于使用 theme_menu_tree() 为自定义菜单设置主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆