Skip to content

Instantly share code, notes, and snippets.

Embed
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_tree_all_data('main-menu');
$menu = menu_build_tree('main-menu');
$menu_items = render(menu_tree_output($menu));
@franciscocorrales

This comment has been minimized.

Copy link

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">
      <ul>
        <li>no link</li>
        <li class="class"><a href=""></a>link 1</li>
        <li class="class"><a href=""></a>link 2</li>
      </ul>
    </div>
    <div class="col-xs-6">
      <ul>
        <li class="class"><a href=""></a>link 3</li>
        <li class="class2"><a href=""></a>link 4</li>
      </ul>
    </div>
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.