The Drupal Man shows how to hide block only for certain content type!
Home > Internet marketing and seo blog > Drupal > Hide block for certain content type in Drupal 6

Hide block for certain content type in Drupal 6

Quite often you want to hide or show a block only for a specific content type in Drupal. There is a quite simple hack you can do for achieving that! This is for Drupal 6, in Drupal 7 there is a core function that lets you do the same. Use this code to hide a block for a certain content type in drupal 6:
<?php
$match = TRUE;
$types = array(‘library’ => 1);
if (arg(0) == ‘node’ && is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load(array(‘nid’ => $nid));
$type = $node->type;
if (isset($types[$type])) {
$match = FALSE;
}
}
if (drupal_is_front_page()) {
$match = FALSE;
}
return $match;
?>

When editing a block, paste this in the box on the bottom of the page and chose “show only if the following php-code returns ‘true’.” Then the block will show on every content type except the “library”-one, and neither on the frontpage. Of course you can change the “library” to whatever content type you want. As you see, a little lower in the code you find this: if (drupal_is_front_page()), that means that we hide it also on the frontpage. Remove that line and the two under it if you don’t want to use that function.

You like posts about Drupal? Then, read also my post about how to create quicktab blocks with cck fields inside.