0

I need to show a block for terms of a certain vocabulery. Drupal.org has this snippit for Drupal 6, but I cant find anything for Drupal 7.

http://drupal.org/node/69076

Im looking at PHP in the block visibility settings as Im assuming its the best way, but id be happy with any other solution. Thanks

4

If you want to do this on the term pages you should be able to use this code from Drupal.org. Just replace the function call taxonomy_get_term with taxonomy_term_load.

The code is copied below:

 <?php
  $desired_vocab = 1; // put here the vocabulary ID you're interested in

  if ( ((arg(0) == 'taxonomy')
    && (arg(1) == 'term')
    && is_numeric(arg(2))
    && ($term = taxonomy_term_load(arg(2)))
    && ($term->vid == $desired_vocab )) ) {
      return TRUE;
  }
?>
| improve this answer | |
1

It's always better to avoid placing PHP in the database. I suggest you use the module Block Visibility by Term.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.