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

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

问题描述

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



但是,我的Drupal没有这样做。每当我启用一个模块(由我写的或由他人贡献的模块或核心模块)时,Drupal似乎没有获得新的信息。新启用的模块中定义的菜单项目不会被处理并插入到Drupal的菜单系统中。这意味着新启用的模块没有机会工作 - 因为它不可访问。



我已经通过手动将新模块的菜单项信息插入到menu_router和menu_links表中,并且新菜单开始工作,从而解决了这个问题。但是,如果我每次启用一个模块都必须这样做,这是一个噩梦。



任何一个有同样的问题?如何解决这个问题?



提前谢谢。

解决方案

我不会使用任何SQL与菜单表进行交互,如果您编辑错误的记录,可能会发生恶作剧。



您的hook_menu代码中必须有错误。你可以粘贴它吗?



另外,如果你正在开发一个有菜单条目的模块,我发现在添加的时候可以方便地在mymodule_init()中调用这两个函数/删除链接

  cache_clear_all()
menu_router_build()
/ pre>

将刷新所有缓存并重建菜单以及调用hook_menu的任何内容。如果没有出现,那么你的代码有一个bug。我想看看。


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.

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.

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?

Thank you in advance.

解决方案

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

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

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()

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天全站免登陆