Skip to main content

Drupal 6.x - display block depending on node type

Use this code in your block when you want to display it on every page of a certain node type

First select php in your input format selection of your block.
Then copy and paste the following code, replacing "your-node-type" with the name of the node type you want to use.

<?php
if (arg(0) == 'your-node-type') {
  return
TRUE;
}
if (
arg(0) == 'node' && ctype_digit(arg(1))) {
 
$node = node_load(arg(1));
  if (
$node->type == 'your-node-type') {
    return
TRUE;
  }  
}
return
FALSE;
?>

to display on every page except the node type, use this code with the true and false reversed:

<?php
if (arg(0) == 'magazine') {
  return
FALSE;
}
if (
arg(0) == 'node' && ctype_digit(arg(1))) {
 
$node = node_load(arg(1));
  if (
$node->type == 'magazine') {
    return
FALSE;
  }  
}
return
TRUE;
?>