Advertisement
Guest User

elvisblogsorg

a guest
Jan 11th, 2010
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. <?php
  2. function themename_child_terms($vid = 1) {
  3.   if((arg(0) == 'taxonomy' && arg(1) == 'term') || (arg(0) == 'node' && is_numeric(arg(2)))) {
  4.  
  5.     if(arg(0) == 'term') {
  6.         $children = taxonomy_get_children(arg(2), $vid); // does this term have children?
  7.         if(!$children) {
  8.         $custom_parent = taxonomy_get_parents(arg(2));
  9.           $parent_tree = array();
  10.           foreach ($custom_parent as $custom_child => $key) {
  11.             $parent_tree = taxonomy_get_tree($vid, $key->tid);
  12.           }
  13.           $children = $parent_tree;
  14.         }
  15.     }
  16.     else { // we are on a node page
  17.         $n = node_load(array('nid' => arg(2)));
  18.         $children = taxonomy_node_get_terms_by_vocabulary($n, $vid);
  19.     }
  20.    
  21.     $output = '<ul>';
  22.     foreach ($children as $term) {
  23.       $output .= '<li>';
  24.       $output .= l($term->name, 'taxonomy/term/' . $term->tid);
  25.       $output .= '</li>';
  26.     }
  27.     $output .= '</ul>';
  28.    
  29.     return $output;
  30.   }
  31. }
  32. ?>
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement