Get Drupal menu down from current page


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $i = 0;
  3. $item = menu_get_item();
  4. $tree = menu_tree_page_data('primary-links');
  5. list($key, $curr) = each($tree);
  6.  
  7. while ($curr) {
  8. // Terminate the loop when we find the current path in the active trail.
  9. if ($curr['link']['href'] == $item['href'] || $i++ > 2) {
  10. $tree = $curr['below'];
  11. $curr = FALSE;
  12. }
  13. else {
  14. // Add the link if it's in the active trail, then move to the link below.
  15. if ($curr['link']['in_active_trail']) {
  16. $tree = $curr['below'] ? $curr['below'] : array();
  17. }
  18. list($key, $curr) = each($tree);
  19. }
  20. }
  21.  
  22. foreach ($tree AS $key => $val){
  23. if ($val['link']['in_active_trail']){
  24. $tree_int = $val['below'];
  25. break;
  26. }
  27. }
  28.  
  29. $menuhtml = theme_menu_tree(menu_tree_output($tree_int));
  30. print $menuhtml;
  31. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.