自定义主题 Drupal 6 菜单
是否有一个钩子或预处理函数可供我访问来为 drupal 菜单编写自己的主题函数(在本例中为主链接)?
我有一个相当复杂的菜单结构,需要一些额外的标记,而不是我目前仅在块中渲染菜单项(涉及带有一些自定义标记的子菜单),并且确实需要访问权限来构建菜单的内容我自己变量,最好来自一个包含所有主链接及其子链接的数组。
Is there a hook or preprocess function that I can access to write my own theming function for a drupal menu (in this case, primary links)?
I have a rather complex menu structure that requires a little extra markup than I'm currently getting by just rendering the menu items in a block (involving sub-menus with a little custom markup) and really need to get access to build the menu's content variable myself, ideally from an array that has all the primary links and their children in scope.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然它可能不是最好的解决方案,但它的工作速度非常快且轻松:
Drupal 在cache_menu 表中保留所有菜单的缓存版本,我运行了一个此查询来检索包含菜单所有内容的序列化字符串:
用 Primary_links 替换菜单的名称,并调用 $row->data 上的 unserialize 来获取构建自定义菜单所需的所有内容的结构化数组。
我在 hook_preprocess_block 中调用一个函数,该函数将菜单块的内容与我自己的内容交换,一切似乎都工作正常。
While it may not be the best solution, it is one that worked quite quickly and painlessly:
Drupal keeps a cached version of all your menus in the cache_menu table, I ran a this query to retreive a serialized string containing all the contents of the menu:
Substitute primary_links for whatever the name of your menu is and call unserialize on $row->data to get a structured array of everything you should need to build a custom menu.
I call a function in hook_preprocess_block that swaps the content of the menu block with my own and everything seems to be working fine.