Return to Snippet

Revision: 42683
at March 9, 2011 02:54 by Risse


Initial Code
<?php
  // Only show if $match is true
  $match = false;

  // Which node types
  $types = array('book', 'news', 'anothernodetype' );

  // Match current node type with array of types
  if (arg(0) == 'node' && is_numeric(arg(1))) {
    $nid = arg(1);
    $node = node_load(array('nid' => $nid));
    $type = $node->type; 
    $match |= in_array($type, $types);
  }

  return $match;
?>

Initial URL

                                

Initial Description

                                

Initial Title
Drupal show block only on node type

Initial Tags
php, drupal

Initial Language
PHP