Skip to content

Instantly share code, notes, and snippets.

@mootari
Last active August 29, 2015 14:19
Show Gist options
  • Save mootari/1a7c81509b59027c4f17 to your computer and use it in GitHub Desktop.
Save mootari/1a7c81509b59027c4f17 to your computer and use it in GitHub Desktop.
Renders a Drupal submenu tree without using menu_block. #drupal-7 #menu-tree
<?php
/**
* Renders a submenu tree.
*
* @param string $menu
* The internal menu name
* @param string $path
* The path. May be an alias.
* @return array
* Menu tree render array
*/
function EXAMPLE_build_menu_tree($menu, $path) {
$link = menu_link_get_preferred(drupal_get_normal_path($path));
if(empty($link['depth'])) {
return array();
}
$parameters = array(
'min_depth' => $link['depth'] + 1,
'conditions' => array('p' . $link['depth'] => $link['mlid']),
);
$tree = menu_build_tree($menu, $parameters);
return menu_tree_output($tree);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment