You are here

function nicemessages_pages_visibility in Nice messages 7

Same name and namespace in other branches
  1. 8.2 nicemessages.module \nicemessages_pages_visibility()
  2. 7.2 nicemessages.module \nicemessages_pages_visibility()

Show nicemessages on specific pages

1 call to nicemessages_pages_visibility()
nicemessages_preprocess_page in ./nicemessages.module
Implements hook_preprocess_page().

File

./nicemessages.module, line 93
Nicemessages module

Code

function nicemessages_pages_visibility() {
  $pages = variable_get('nicemessages_pages');
  $visibility = variable_get('nicemessages_visibility');
  if (!empty($pages)) {

    // Convert path to lowercase. This allows comparison of the same path
    // with different case. Ex: /Page, /page, /PAGE.
    $pages = drupal_strtolower($pages);

    // Convert the Drupal path to lowercase
    $path = drupal_strtolower(drupal_get_path_alias($_GET['q']));

    // Compare the lowercase internal and lowercase path alias (if any).
    $page_match = drupal_match_path($path, $pages);

    // When $visibility has a value of 0
    // the block is displayed on all pages except those listed in $pages.
    // When set to 1,
    // it is displayed only on those pages listed in $pages.
    $page_match = !($visibility xor $page_match);
    if ($page_match) {
      return TRUE;
    }
  }
  return FALSE;
}