You are here

function _menu_node_tree in Menu Node API 7

Same name and namespace in other branches
  1. 6 menu_node.module \_menu_node_tree()

A private recursive sort function.

Given a menu tree, return its child node links.

Parameters

$tree: The recursive tree data.

$menu: The menu that this data belongs to.

$data: The tree data for this menu element.

$parents: An array of menu link ids indicating the tree elements to return.

$marker: A string (or NULL) to prepend to the menu link title, indicating relative depth.

$spacer: A string (or NULL) to place between the marker and the title.

Return value

No return. Modify $tree by reference.

1 call to _menu_node_tree()
menu_node_tree in ./menu_node.module
Public function for generating a tree representation of nodes in a menu.

File

./menu_node.module, line 247
Menu Node API Manages relationships between the {node} and {menu_links} table.

Code

function _menu_node_tree(&$tree, $menu, $data, $parents, $marker = NULL, $spacer = NULL) {
  if (empty($tree)) {
    $tree = array();
  }
  if (empty($parents)) {
    $parents = array();
  }
  if (in_array($data['link']['mlid'], $parents)) {
    $parent = menu_node_get_parent($data['link']);
    $tree[$parent][$data['link']['mlid']] = str_repeat($marker, $data['link']['depth']) . $spacer . $data['link']['title'] . ' ';
  }
  if (!empty($data['below'])) {

    // Recursive processing joy!
    foreach ($data['below'] as $value) {
      _menu_node_tree($tree, $menu, $value, $parents, $marker, $spacer);
    }
  }
}