block_exclude_pages.module in Block Exclude Pages 7
File
block_exclude_pages.module
View source
<?php
function block_exclude_pages_blockhelptext() {
$description = "<ul>";
$description .= "<li>" . t("Specify pages by using their paths. Enter one path per line. Using") . "<em class='placeholder'>node/[nid]</em> " . t("is recommended as pages aliases can change on page editing.") . "</li>";
$description .= "<li>" . t("The '*' character is a wildcard. Example paths are user for the current user's page and user/* for every user page.") . "</li>";
$description .= "<li>" . t("To exclude Specific pages, prefix the path with a '!', Example excluded path") . "<em class='placeholder'>!user/jc</em></li>";
$description .= "</ul>";
$description = $description;
return $description;
}
function block_exclude_pages_form_block_admin_configure_alter(&$form, &$form_state, $form_id) {
$description = block_exclude_pages_blockhelptext();
$form['visibility']['path']['pages']['#description'] = t($description);
}
function block_exclude_pages_block_view_alter(&$data, $block) {
if ($block->visibility == 1) {
$path = $_GET['q'];
$path_alias = drupal_strtolower(drupal_get_path_alias($path));
$pages = preg_split('/\\n|\\r\\n?/', $block->pages);
$exclude_string = '';
foreach ($pages as $page) {
if (substr($page, 0, 1) == "!") {
$exclude_string .= drupal_strtolower(substr($page, 1)) . "\r\n";
}
}
if (!empty($exclude_string)) {
$page_match = drupal_match_path($path_alias, $exclude_string);
if ($path_alias != $path) {
$page_match = $page_match || drupal_match_path($path, $exclude_string);
}
if ($page_match) {
$data['subject_array'] = NULL;
$data['subject'] = NULL;
$data['content'] = NULL;
}
}
}
}