创建链接到其父级的菜单项
我一直在寻找低点和高点来做到这一点。我想以编程方式创建一个链接到其父级的普通菜单项。类似于默认菜单任务的概念,但只是一个普通的菜单项。有人这样做过吗?
我想要一些可以用 drupal 钩子做的事情。
I've been searching low an high to do this. I want to create a normal menu item programatically that links to its parent. Similar to the concept of default menu task, but just a normal menu item. Has anyone ever done this?
I want something that I can do with one of the drupal hooks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这应该可以解决问题:)
This should do the trick :)
假设您想将其放在主菜单下,
您将在主菜单下获得菜单项(清除缓存)。诀窍是添加一个键“menu_name”。
要获取menu_name,请打开菜单管理页面,然后单击任意根菜单上的“编辑菜单”。 URL 将类似于“SITE_URL/admin/struct/menu/manage/main-menu/edit”。查看最后一个(这里是主菜单)之前的 url 段。
对于第二种情况,您可能希望将其放置在主菜单的“Home”下。代码是。
在这里,我向关联数组添加了一个键 pld,它是菜单项(此处为“Home”)的 mlid,它将成为该菜单项的子项。对于这种情况,它将是主菜单的子菜单。
要获取 mlid,您必须执行与上述相同的操作,转到菜单管理页面并单击列表链接,然后单击菜单项上的编辑,例如 SITE_URL/admin/struct/menu/item/218/edit,这样您就可以获得mlid 就这样完成了。
笔记。如果您从后端更改此菜单层次结构或其他设置,您将始终有重置选项来重置它,并且重置后它将像代码中描述的那样运行。
Suppose you want to place it under Main menu,
You will then get the menu item under Main menu (clearing cache). The trick is adding a key 'menu_name'.
To get the menu_name please open the menu administration page, and click on 'edit menu' on any root menu. URL will be like 'SITE_URL/admin/structure/menu/manage/main-menu/edit'. Look at the url segment just before the last(here main-menu).
For the second case you might want to place it under Home of main menu. The code is.
Here, I have added a key plid to associative array, it is the mlid of the menu item('Home' here) for which it will be a child. For this case it will be child of Home menu.
To get the mlid you have to do the same as described above, goto menu administration page and click list links and then click edit on the menu item, e.g. SITE_URL/admin/structure/menu/item/218/edit, thus you can get the mlid and thus its done.
Note. If you change this menu hierarchy or other settings from back-end, you will always have reset option to reset it, and after resetting it will behave like described in the code.
您只需要创建一个新的菜单项,与其父项具有相同的路径。
You just need to create a new menu-item, that has the same path as its parent.