Drupal show block only on node type


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. // Only show if $match is true
  3. $match = false;
  4.  
  5. // Which node types
  6. $types = array('book', 'news', 'anothernodetype' );
  7.  
  8. // Match current node type with array of types
  9. if (arg(0) == 'node' && is_numeric(arg(1))) {
  10. $nid = arg(1);
  11. $node = node_load(array('nid' => $nid));
  12. $type = $node->type;
  13. $match |= in_array($type, $types);
  14. }
  15.  
  16. return $match;
  17. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.