menu_node_tree

Versions
menu_node
menu_node_tree($tree, $menu = NULL, $filter = array(), $options = array())

Public function for generating a tree representation of nodes in a menu.

This function is useful for showing the relationship between nodes within a given menu tree. It can be used to build options lists for forms and other user interface elements.

Parameters

$tree The parent menu tree, generated by menu_tree_all_data().

$menu The name of the menu for which to return data.

$filter An array of menu links ids that indicate the only children to return. That is, if this array is populated, only its members and their children will be returned by this function.

$options An array of processing options. The valid options are 'marker' and 'spacer'. -- 'marker' indicates a text mark to indicate menu depth for a menu link. -- 'spacer' indicates the text string to insert betwen a marker and its link title.

Return value

A nested array of menu data.

Code

./menu_node.module, line 145

<?php
function menu_node_tree($tree, $menu = NULL, $filter = array(), $options = array()) {
  $options += array('marker' => '-', 'spacer' => ' ');
  $data = array();
  if (!empty($menu)) {
    _menu_node_tree($data, $menu, $value, $filter, $options['marker'], $options['spacer']);
    return $data[$menu];
  }
  else {
    foreach ($tree as $key => $value) {
      _menu_node_tree($data, $key, $value, $filter, $options['marker'], $options['spacer']);
    }
  }
  return $data;
}
?>

Contact

  • agentrickard [at] gmail [dot] com

Donations

My Amazon.com Wish List