D6
<?php
if ( arg(0) == 'node' and is_numeric(arg(1)) and arg(2) == FALSE ) {
// Vocabulary term ID for which to display the block:
$displayTermID =1;
// Get all taxonomy terms for current node:
$currNodeTerms = taxonomy_node_get_terms(node_load(arg(1)));
// If there are no terms, fail-fast:
if (is_null($currNodeTerms) || 0 == count($currNodeTerms)) {
return FALSE;
}
// For each term of the current node, get all the ancestor terms:
foreach($currNodeTerms as $term) {
$ancestors = taxonomy_get_parents_all($term->tid);
// Check for each ancestor term whether it is the term we are looking for.
// If it is, return TRUE immediately:
if (!is_null($ancestors) && 0 < count($ancestors)) {
foreach($ancestors as $ancestor) {
if ($displayTermID == $ancestor->tid) {
return TRUE;
}
}
}
}
}
// If we didn't find our term of interest, return FALSE:
return FALSE;
?>
D7
<?php
$term_id_to_trigger_show_block = 109;
if ((arg(0) == 'node') && is_numeric(arg(1))) {
$node = node_load(arg(1));
$terms = taxonomy_node_get_terms($node);
foreach($terms as $term) {
if ($term->tid == $term_id_to_trigger_show_block) {
return TRUE;
}
}
}
?>
http://stackoverflow.com/questions/3193745/drupal-display-blocks-accord…