[support] PHP: block visibility by term
crozilla
crozilla at gmail.com
Tue Aug 5 19:39:29 UTC 2008
All,
I kinda know what I'm doing in Drupal, but this trick has baffled me.
This is what I want to have happen: When the page has the term 221,
block/24 is visible, when the page doesn't have the term, the block is
disabled. Sounds simple, right?
Here is code I found on Drupal that seemed to do what I wanted, but
didn't work for some reason. I don't really know PHP that well, and was
hoping someone could point out the problem.
------------------
|
<?php
//code snippet for causing block to show based on a node's taxonomy term.
$make_block_visible = FALSE;
$term_id_to_trigger_show_block = 221;
if ((arg(0) == 'node') && is_numeric(arg(1))) {
$terms = taxonomy_node_get_terms(arg(1));
foreach($terms as $term) {
if ($term->tid == $term_id_to_trigger_show_block) {
$make_block_visible = TRUE;
}
}
}
?>
------------
|Also, is this possible using a CCK text field, instead of a category
term? That would be ideal.
Thanks,
Peter
More information about the support
mailing list