You are here

function filter_harmonizer_is_new_page in Views Filter Harmonizer 7

Returns TRUE when the current page is different from the previous.

This also captures as "is new" any changes in the contextual filter arguments in the URL. Calling this function more than once during the same request, will NOT result in a different value.

Return value

bool TRUE when the current page (i.e. URL) is different from the previous.

2 calls to filter_harmonizer_is_new_page()
filter_harmonizer_init in ./filter_harmonizer.module
Implements hook_init().
filter_harmonizer_views_exposed_form_submit in ./filter_harmonizer.module
Supplementary submit handler for 'views_exposed_form'.

File

./filter_harmonizer.module, line 372
filter_harmonizer.module For Views where both exposed and contextual filters are active on a page.

Code

function filter_harmonizer_is_new_page() {
  $is_new =& drupal_static(__FUNCTION__, NULL);
  if (!isset($is_new)) {

    // Next call will always return views/ajax for Views with "Use AJAX: Yes"
    $path = current_path();
    if (module_exists('session_cache')) {
      $session = session_cache_get('filter_harmonizer');
      $previous_path = isset($session['prev_path']) ? $session['prev_path'] : FALSE;
      $session['prev_path'] = $path;
      session_cache_set('filter_harmonizer', $session);
    }
    else {
      $previous_path = isset($_SESSION) && isset($_SESSION['filter_harmonizer']['prev_path']) ? $_SESSION['filter_harmonizer']['prev_path'] : FALSE;
      $_SESSION['filter_harmonizer']['prev_path'] = $path;
    }
    $is_new = $previous_path !== $path;
  }
  return $is_new;
}