Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Render menu programmatically in Drupal 7
// One level menu.
$menu = menu_tree('main-menu');
$menu_items = render($menu);
// Menu with many levels.
$menu = menu_build_tree('main-menu');
$menu_items = render(menu_tree_output($menu));

This comment has been minimized.

Copy link

@franciscocorrales franciscocorrales commented Jan 19, 2017

What if I want to add custom HTML ?, is there a way to go through the elements (links) ?

Example HTML:

    <div class="col-xs-6">
        <li>no link</li>
        <li class="class"><a href=""></a>link 1</li>
        <li class="class"><a href=""></a>link 2</li>
    <div class="col-xs-6">
        <li class="class"><a href=""></a>link 3</li>
        <li class="class2"><a href=""></a>link 4</li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.