Block visibility based on TERM: Site Sections

<?php
// This snippet returns TRUE if the node we are
// currently viewing is tagged with a term which is
// the ‘desired_term’ and we are not in edit mode (arg(2)).

// put here the term ID you’re interested in
$desired_term = 59;

if ( arg(0) == ‘node’ and is_numeric(arg(1)) and arg(2) == FALSE ) {
// Yes, we’re viewing a node in view mode.

$node = node_load(arg(1)); // cached
// If the term does not exist we’re done
if (is_array($node->taxonomy)) {
foreach (
$node->taxonomy as $term) {
if (
$term->tid == $desired_term) {
return
TRUE;
}
}
}
}
return
FALSE;
?>

About the Author

Follow me on Twitter @karlbinder