Posted By

jahmal on 10/15/10


Tagged

menu drupal


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

ddtfish
titosemi


Get Drupal menu down from current page


 / Published in: PHP
 

  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  

You need to login to post a comment.