Skip to content

Instantly share code, notes, and snippets.

@ranqiangjun
Forked from eugene-ilyin/render_menu.php
Created January 13, 2016 07:58
Show Gist options
  • Save ranqiangjun/e3e5857e9796ba6ae963 to your computer and use it in GitHub Desktop.
Save ranqiangjun/e3e5857e9796ba6ae963 to your computer and use it in GitHub Desktop.
Render menu programmatically in Drupal 7
// One level menu.
$menu = menu_tree('main-menu');
$menu_items = render($menu);
// Menu with many levels.
menu_tree_all_data('main-menu');
$menu = menu_build_tree('main-menu');
$menu_items = render(menu_tree_output($menu));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment