16 May 2009

Display block on specific terms in Drupal 6.x

If you want to show block by specific terms each node in drupal 6.x. You can use php condition for display your block.

  1. Go to Administer > Sites building > Block
  2. Configure your block
  3. Open Page specific visibility settings > Show if the following PHP code returns TRUE (PHP-mode, experts only). and paste this code.

if (arg(0)=='node' && is_numeric(arg(1)) ) {
  $terms = taxonomy_node_get_terms(node_load(arg(1)));
  foreach($terms as $term) {
    if (in_array($term->name, array('term1_name', 'term2_name'))) {
      return TRUE;
return FALSE;

NOTE: You can change $term->name (for term name) to $term->tid (for term id).

Special thanks: @noomz
More information: taxonomy_node_get_terms (api.drupal.org)
Related story: Display Block on a Specific Content Type in Drupal 6.x (musida.web.id)