Drupal 6 无法构建菜单路由器和链接 [英] Drupal 6 fails to build menu router and links

查看:24
本文介绍了Drupal 6 无法构建菜单路由器和链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 Drupal 中启用一个新菜单(例如 mymodule)时,Drupal 应该能够从 mymodule_menu (hook_menu) 中获取菜单项,处理这些项并将菜单项插入到 menu_router 和 menu_links 表中.

When I enable a new menu in Drupal (for example, mymodule), Drupal should be able to get the menu items from mymodule_menu (hook_menu), process the items and insert the menu items to menu_router and menu_links table.

然而,我的 Drupal 没有这样做.每次我启用一个模块(由我编写或其他人贡献的模块,或核心模块)时,Drupal 似乎无法获取新信息.在新启用的模块中定义的菜单项不会被处理并插入到 Drupal 的菜单系统中.这意味着新启用的模块没有机会工作——因为它无法访问.

However, my Drupal fails to do so. Each time I enable a module (written by me or modules contributed by others, or core modules), Drupal does not seem to get the new information. The menu items defined in the newly enabled module are not processed and inserted to Drupal's menu system. That means the newly enabled module has no chance to work-- because it's inaccessible.

我确实通过将新模块的菜单项信息手动插入到 menu_router 和 menu_links 表中来解决此问题,并且新菜单开始工作.但是,如果每次启用模块时都必须这样做,这将是一场噩梦.

I did fix this by manually insert the menu item information for the new module into the menu_router and menu_links table and the new menu started working. But this is a nightmare if I have to do this each time I enable a module.

有人遇到过同样的问题吗?如何解决这个问题?

Any one has ever had the same problem? How to fix this?

提前致谢.

推荐答案

我不会使用任何 SQL 与菜单表进行交互,如果您编辑错误的记录,可能会发生一些令人讨厌的事情.

I would not use any SQL to interact with the menu tables, something nasty could happen if you edit the wrong record.

您的 hook_menu 代码中肯定有错误.可以粘贴吗?

You must have an error in your hook_menu code. Can you paste it?

此外,如果您正在开发具有菜单项的模块,我发现在添加/删除链接时在 mymodule_init() 内部调用这两个函数很方便:

Also, if you are developing a module that has menu entries, I find that its handy to call these two functions inside of mymodule_init() when adding/removing links:

cache_clear_all()
menu_router_build()

这将刷新所有缓存并重建菜单以及调用 hook_menu 的任何内容.如果在那之后它没有出现,那么你的代码有一个错误.我想看看.

That will flush all cache and rebuild the menu and anything invoking hook_menu. If it doesn't appear after that, then your code has a bug. I'd like to see it.

这篇关于Drupal 6 无法构建菜单路由器和链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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