Return to Snippet

Revision: 22099
at January 1, 2010 11:48 by BoNzO


Initial Code
<?php
/* a list a pages to include in standard block include/exclude format (one per line) */
$include = "some/site/section/*
another/page/here
node/34";

/* a list a pages to exclude in standard block include/exclude format (one per line) */
$exclude = "some/site/section/page1
some/site/section/page2";

/* ----------- DO NOT TOUCH ANYTHING BELOW THIS LINE ----------- */
$match = FALSE;
$path = drupal_get_path_alias($_GET['q']);
$regexp = '/^('. preg_replace(array('/(
?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($include, '/')) .')$/';
if (preg_match($regexp, $path)) {
  $regexp = '/^('. preg_replace(array('/(
?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($exclude, '/')) .')$/';
  if (!preg_match($regexp, $path)) {
    $match = TRUE;
  }
}
return $match;
?>

Initial URL


Initial Description


Initial Title
Make a Drupal Block Visible for Entire Site Sections but NOT Specific Sub-sections or Pages

Initial Tags
drupal

Initial Language
PHP