在自定义模块中使用主题功能
这是一个非常具体的问题,可能没有一个优雅的答案。我想在两个站点之间共享菜单,一个是 Drupal,一个不是。我正在使用自定义模块来实现 hook_menu_link_alter 并希望将主题菜单输出到文件中。关于这一点没有讨论,我们只需要为其他站点公开一个 html 文件。我知道通过循环并重新创建主题函数已经执行的操作来实现此目的的一种强力方法,但我认为也许有一种方法可以实际直接使用主题函数。
现在我正在尝试...
theme('links', theme('navigation-links', 'menu-name'), array('id' => 'menu-id'));
但没有收到任何输出。我也没有收到任何错误,这真是令人遗憾。 (注意:我并不是 100% 认为导航链接的主题功能实际上是 theme('navigation-links''))。
有什么想法吗?
(注意:我也在新的 Drupal StackExchange 站点上发布了这个问题,但可能会删除它,因为社区尚不存在)
This is a pretty specific issue which may not have an elegant answer. I want to share a menu across two sites one Drupal and one not. I'm using a custom module to implement hook_menu_link_alter and want to output a themed menu to a file. There's no discussion on this point, we need to just expose an html file for the other site. I know a brute force way to do this by just looping through and just re-creating what the theming function already does, but I thought maybe there was a way to actually use the theming function directly.
Right now I'm trying...
theme('links', theme('navigation-links', 'menu-name'), array('id' => 'menu-id'));
but am receiving no output. I'm also receiving no errors, which is a bummer. (Note: I'm not 100% that the theming function for navigation-links is actually theme('navigation-links'')).
Any ideas?
(Note: I alos posted this question over at the new Drupal StackExchange site but may remove it as the community isn't there yet)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
链接的主题功能需要一组主题链接。
你可以使用类似的东西:
函数menu_navigation_links()存在于includes/menu.inc中,它使用函数menu_tree_page_data()根据当前返回菜单的树数据您正在查看的页面。
您可以使用名为 menu_tree_all_data() 的类似函数,但您必须对其返回的数据执行与 menu_navigation_links() 相同的操作。否则,您仍然会得到空菜单。
the theming function for links needs an array of links to theme.
you can use something like:
The function menu_navigation_links() exists in includes/menu.inc and it uses the function menu_tree_page_data() which returns the menu's tree data according to the current page you're viewing.
You can use a similar function called menu_tree_all_data(), but you'll have to do the same manipulations that menu_navigation_links() does on the data it returns. otherwise, you'll still get empty menus.