Taxonomy based block visibility snippet

//Displays block on all nodes off specific taxonomy term or it's child terms. Mighty useful in lots of cases. <?php $root_term = taxonomy_get_term(54); $tree = taxonomy_get_tree($root_term->vid, $root_term->tid); $terms = array_map('_taxonomy_get_tid_from_term', $tree); $terms[] = $root_term->tid; // $terms now contains all descendant terms. //print_r( $terms ); if ((arg(0) == 'node') && is_numeric(arg(1))) { $node = node_load(arg(1)); if (array_intersect(array_keys($node->taxonomy), $terms)) return TRUE; } if ( (arg(0) == 'taxonomy') && (arg(1) == 'term') && in_array(arg(2), $terms) ) { return TRUE; } return FALSE; ?>

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
ನೀವು ಮನುಷ್ಯರೇ ಎಂದು ನಮಗೆ ಖಾತ್ರಿಯಾಗಬೇಕಿದೆ!