Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function themename_child_terms($vid = 1) {
- if((arg(0) == 'taxonomy' && arg(1) == 'term') || (arg(0) == 'node' && is_numeric(arg(2)))) {
- if(arg(0) == 'term') {
- $children = taxonomy_get_children(arg(2), $vid); // does this term have children?
- if(!$children) {
- $custom_parent = taxonomy_get_parents(arg(2));
- $parent_tree = array();
- foreach ($custom_parent as $custom_child => $key) {
- $parent_tree = taxonomy_get_tree($vid, $key->tid);
- }
- $children = $parent_tree;
- }
- }
- else { // we are on a node page
- $n = node_load(array('nid' => arg(2)));
- $children = taxonomy_node_get_terms_by_vocabulary($n, $vid);
- }
- $output = '<ul>';
- foreach ($children as $term) {
- $output .= '<li>';
- $output .= l($term->name, 'taxonomy/term/' . $term->tid);
- $output .= '</li>';
- }
- $output .= '</ul>';
- return $output;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement