Your Ad Here

Posted By

theroamingcoder on 01/22/10


Tagged

page links drupal primary children 6x Landing


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

EkTrOn
Onfire60
titosemi
ctronci


Drupal 6 Show Child Primary Links In Page


 / Published in: PHP
 

This code is ideal for situations where you have expandable primary links that don't particularly need their own page, but you would like to have links to the child menu items for users that do not have javascript enabled, or so on...

  1. <?php
  2. function find_plink_item($tree, $search_path){
  3. foreach($tree as $plink){
  4. if($plink['link']['link_path'] == $search_path){
  5. return $plink;
  6. }
  7. if(is_array($plink['below'])){
  8. $subsearch = find_plink_item($plink['below'], $search_path);
  9. if($subsearch){
  10. return $subsearch;
  11. }
  12. }
  13. }
  14. return NULL;
  15. }
  16. if(is_numeric(arg(1)) and (arg(0) == 'node')){
  17. $my_plink = find_plink_item(menu_tree_page_data('primary-links'), 'node/'.arg(1));
  18. if($my_plink){
  19. foreach($my_plink['below'] as $child_plink){
  20. print '<h3>'.l($child_plink['link']['link_title'],$child_plink['link']['link_path']).'</h3>';
  21. }
  22. }
  23. }
  24. ?>

Report this snippet  

You need to login to post a comment.