如何分离管理菜单?

发布于 2024-09-14 23:46:01 字数 96 浏览 3 评论 0原文

我想将管理员菜单(以管理员身份登录后出现的菜单)与普通菜单分开。我必须在其他一些块中显示管理菜单。我不喜欢为此使用任何模块,请让我知道如何用代码完成此操作,

谢谢

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉鱼一梦 2024-09-21 23:46:01

您无需任何代码即可完成此操作:

  1. 转到网站建设 -> 菜单 -> 添加菜单
  2. 创建您的菜单,例如管理菜单,然后保存。
  3. 进入网站建设 -> 菜单 -> 导航
  4. 单击“管理”菜单项旁边的“编辑”链接。
  5. 父菜单更改为新菜单并保存。

您的新菜单现在将包含整个管理菜单树,并且它将脱离原始导航菜单。从那里,您可以根据自己的喜好移动菜单的每个部分。

不过,这种方式并非没有问题:仍然有一些模块依赖于特定位置的管理菜单,这会造成混乱。

我鼓励您重新思考您对模块的厌恶:这确实违背了 Drupal 的精神。几乎所有的东西都已经被创建为 Drupal 模块,我们鼓励您从开源社区中获益。

例如,为了避免我概述的方法的陷阱,有两个模块可以真正提供帮助:第一个是 管理菜单:启用它即可。管理菜单将从导航菜单中消失,并且您将拥有一个新的管理菜单,该菜单将出现在每个页面上以便于访问。

第二个是菜单块,它允许您创建子菜单块。如果您启用了它,您可以:

  1. 转到网站建设 -> -> 添加菜单块
  2. 父级下,选择菜单:导航项目:--管理
  3. 保存该块。您现在有一个可用的块,其中仅包含管理菜单。

现在,您将在单独的块中拥有管理菜单,以便您可以随意使用。

You can do this without any code:

  1. Go to Site building -> Menus -> Add menu.
  2. Create your menu, let's say Admin menu, and save it.
  3. Go into Site building -> Menus -> Navigation.
  4. Click the edit link next to the Administer menu item.
  5. Change the Parent to your new menu and save.

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:

  1. Go to Site Building -> Blocks -> Add menu block.
  2. Under Parent, select Menu: Navigation and Item: --Administer.
  3. Save the block. You now have a block available that contains just the administration menu.

You'll now have the administration menu in a separate block to do with as you please.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文