Your Ad Here

Posted By

theroamingcoder on 06/09/10


Tagged

visibility drupal block


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ctronci


Drupal hide block for content type


 / Published in: PHP
 

This example is specific to where the "Show on every page except the listed pages." item was selected, but then we needed to also make sure the block did not show for any page of a certain type.

  1. <?php
  2. //Do not show block on event node types
  3. $types = array('event' => 1);
  4. if (arg(0) == 'node' && is_numeric(arg(1))) {
  5. $nid = arg(1);
  6. $node = node_load(array('nid' => $nid));
  7. if (isset($types[$node->type])) {
  8. return FALSE;
  9. }
  10. }
  11.  
  12. //Do not show block on these paths
  13. $exclude_paths = '
  14. <front>
  15. calendar
  16. ';
  17.  
  18. $path = drupal_get_path_alias($_GET['q']);
  19.  
  20. if(drupal_match_path($path, $exclude_paths)){
  21. return FALSE;
  22. }
  23.  
  24. //otherwise show block
  25. return TRUE;
  26. ?>

Report this snippet  

You need to login to post a comment.