elvisblogsorg
By: a guest | Jan 11th, 2010 | Syntax:
PHP | Size: 0.90 KB | Hits: 302 | Expires: Never
<?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));
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;
}
}
?>