0

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.

 <ul>
  <? 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; ?>
    </ul>
   </li>
        <? 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; ?>
 </ul>
0

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

1
  • 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
0

This is what I was looking for:

      <?php 
            $tree = menu_tree_all_data('menu-mobile-menu'); 
            menu_tree_add_active_path($tree);
            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.