[support] PHP: block visibility by term
bharani kumar
bharanikumariyerphp at gmail.com
Thu Aug 7 08:27:10 UTC 2008
$tid = substr($_SERVER['REQUEST_URI'],12,17);
$term = taxonomy_get_term($tid) ;
$node = node_load(arg(1));
if (arg(0) == 'section' && $term->name == 'Events') {
return TRUE;
}
else {
return FALSE ;
}
On Wed, Aug 6, 2008 at 1:09 AM, crozilla <crozilla at gmail.com> wrote:
> 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
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20080807/c3d440a9/attachment.htm
More information about the support
mailing list