Posted By

Risse on 03/09/11


Tagged

php node drupal block


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

variantstudios


Drupal show block only on node type


 / Published in: PHP
 

  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  

You need to login to post a comment.