Display Blocks On Specified Node Types in Drupal

Posted by Mr PHP on

This code snippet will allow you to only display a block on the node types you select. Simply paste into the PHP options.

<?php

$types = array('page','story');

$match = FALSE;
if (arg(0) == 'node' && is_numeric(arg(1))) {
  $nid = arg(1);
  $node = node_load(array('nid' => $nid));
  $type = $node->type;
  if (in_array($type,$types)) {
    $match = TRUE;
  }
}
return $match;

Tagged with : Drupal


Comments