menu_tree_data

function menu_tree_data

menu_tree_data(array $links, array $parents = array(), $depth = 1)

Sorts and returns the built data representing a menu tree.

Parameters

$links: A flat array of menu links that are part of the menu. Each array element is an associative array of information about the menu link, containing the fields from the {menu_links} table, and optionally additional information from the {menu_router} table, if the menu item appears in both tables. This array must be ordered depth-first. See _menu_build_tree() for a sample query.

$parents: An array of the menu link ID values that are in the path from the current page to the root of the menu tree.

$depth: The minimum depth to include in the returned menu tree.

Return value

An array of menu links in the form of a tree. Each item in the tree is an associative array containing:

  • link: The menu link item from $links, with additional element 'in_active_trail' (TRUE if the link ID was in $parents).
  • below: An array containing the sub-tree of this item, where each element is a tree item array with 'link' and 'below' elements. This array will be empty if the menu item has no items in its sub-tree having a depth greater than or equal to $depth.

Related topics

File

includes/menu.inc, line 1564
API for the Drupal menu system.

Code

function menu_tree_data(array $links, array $parents = array(), $depth = 1) {
  // Reverse the array so we can use the more efficient array_pop() function.
  $links = array_reverse($links);
  return _menu_tree_data($links, $parents, $depth);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!menu.inc/function/menu_tree_data/7.x

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部