Add subitem to second level

℡╲_俬逩灬. 提交于 2019-12-24 09:50:29

问题


I have primary links created manually. The are links to node (content type 'page') like

-About
--About Us
--About company

I need to add subitems About/About company/company1 and About/About company/company2 from my module.

Next lines create menu item in first level (in one level with -About)

$items['about2'] = array(
  'menu_name' => 'primary-links',
  'title' => 'About2',
  'page callback' => 'ninegm_about2',
  'access callback' => TRUE,
  'weight' => -10,
);

回答1:


Check out the documentation at the Drupal API site. The path of the menu item, and the hierarchical organization, is determined by the key you pass to $items when defining a new menu item. Right now you are making a completely new top-level menu item.

So you need to replace $items['about2'] with something like this:

$items['About/About company/about2'] = array(
//rest of menu item definition . . .

This will make the new menu item a child of the menu items in its path, so it will come out looking like this:

-About

--About Company

---About2

This is assuming the path to your root about page is "About", and the path to your About Company page is "About company". If that isn't true, just replace them with the real paths to those pages.



来源:https://stackoverflow.com/questions/3391302/add-subitem-to-second-level

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!