Is there an easy way to get the active menu trail in this nav ul? I don't really understand PHP yet, I'm still learning. I personally would have setup the menu in Drupal, not in the html.tpl.php.

  <? foreach($full_menu_items as $menu_item) : ?>
  <? if($menu_item['#original_link']['has_children'] == '1') : $belowMenu = $menu_item['#below'] ?>

  <li class="<? { echo "";  } ?>">
  <div><? echo $menu_item['#original_link']['link_title'] ?></div>
    <ul class="submenu">
       <? foreach($belowMenu as $sub_menu_item) : ?>
       <? if($sub_menu_item['#original_link']['link_path']): ?>
         <li><a href="<? echo $sub_menu_item['#original_link']['link_path']; ?>"><? echo $sub_menu_item['#original_link']['link_title']; ?></a></li>
       <? endif; ?>
       <? endforeach; ?>
        <? else: ?>
   <? if($menu_item['#original_link']['link_path']): ?>
   <li><a href="<? echo $menu_item['#original_link']['link_path']; ?>"><? echo $menu_item['#original_link']['link_title']; ?></a></li>
   <? endif; ?>

   <? endif; ?>
   <? endforeach; ?>

Use menu_tree_page_data to get an array of the menu items. Set the trail accordingly there.

Example: http://brightplumbox.com/30Drupal7API/#/7/4

  • Thank you, I appreciate it! Quick question: what php tags do I need to put around that, and then 'print $tree' or something to display it? I'm very new to php code. Jul 7 '14 at 6:22

This is what I was looking for:

            $tree = menu_tree_all_data('menu-mobile-menu'); 
            print drupal_render(menu_tree_output($tree));


So much easier / nicer. And editable in Drupal, not the tpl files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.