function menu_node_tree in Menu Node API 7
Same name and namespace in other branches
- 6 menu_node.module \menu_node_tree()
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.
File
- ./
menu_node.module, line 209 - Menu Node API Manages relationships between the {node} and {menu_links} table.
Code
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;
}