如何分离管理菜单?
我想将管理员菜单(以管理员身份登录后出现的菜单)与普通菜单分开。我必须在其他一些块中显示管理菜单。我不喜欢为此使用任何模块,请让我知道如何用代码完成此操作,
谢谢
I would like to separate administrator menus (the menus that appear after login as admin) from normal menus. I have to show admin menus in some other blocks. I don't like to use any modules for this, let me know how can done this with code,
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无需任何代码即可完成此操作:
您的新菜单现在将包含整个管理菜单树,并且它将脱离原始导航菜单。从那里,您可以根据自己的喜好移动菜单的每个部分。
不过,这种方式并非没有问题:仍然有一些模块依赖于特定位置的管理菜单,这会造成混乱。
我鼓励您重新思考您对模块的厌恶:这确实违背了 Drupal 的精神。几乎所有的东西都已经被创建为 Drupal 模块,我们鼓励您从开源社区中获益。
例如,为了避免我概述的方法的陷阱,有两个模块可以真正提供帮助:第一个是 管理菜单:启用它即可。管理菜单将从导航菜单中消失,并且您将拥有一个新的管理菜单,该菜单将出现在每个页面上以便于访问。
第二个是菜单块,它允许您创建子菜单块。如果您启用了它,您可以:
现在,您将在单独的块中拥有管理菜单,以便您可以随意使用。
You can do this without any code:
Your new menu will now contain the entire Administer menu tree, and it'll be out of the original Navigation menu. From there, you can move each part of the menu around to your liking.
This way is not without issues, though: there are still modules that depend on the Administration menu being in a specific place, and this messes with that.
I encourage you to re-think your aversion to modules: it's really against the spirit of Drupal. Almost everything under the sun has been already created as a Drupal module, and you're encouraged to reap the benefits of the open-source community.
For example, to avoid the pitfalls of the approach I outlined, there are two modules that can really help: the first one is Administration menu: enable it and that's it. The administer menu will disappear from the Navigation menu, and you'll have a new admin menu that'll appear on every page for easy access.
The second one is Menu block, which lets you create sub-menu blocks. If you have it enabled, you can:
You'll now have the administration menu in a separate block to do with as you please.