You are here

function jquery_ui_filter_preprocess_page in jQuery UI filter 6

Same name and namespace in other branches
  1. 7 dialog/jquery_ui_filter_dialog.module \jquery_ui_filter_preprocess_page()

Implementation of hook_preprocess_page().

The below code is hiding page features and regions based on the selected dialogFeatures. This allows dailogs to optionally have working tabs and even navigation.

There is also an options page-dialog.tpl.php suggestion that can be used to remove additional page.tpl.php features.

File

dialog/jquery_ui_filter_dialog.module, line 349
Opens links inside a jQuery UI dialog widget.

Code

function jquery_ui_filter_preprocess_page(&$variables) {
  if (jquery_ui_filter_dialog_enabled()) {
    global $theme;
    $features = jquery_ui_filter_dialog_get_features();

    // Remove certain variables and/or regions based on predefined settings.
    foreach ($features as $key => $value) {
      if (empty($value) && strpos($key, 'page-') !== FALSE) {
        $name = str_replace('page-', '', $key);
        $variables[$name] = isset($variables[$name]) && is_array($variables[$name]) ? array() : '';
      }
    }

    // Remove regions
    if (empty($features['page-regions'])) {
      $regions = system_region_list($theme);
      foreach (array_keys($regions) as $region) {
        if ($region != 'content') {
          $variables[$region] = '';
        }
      }
    }

    // Add theme suggestion
    $variables['template_files'][] = 'page-dialog';

    // Add dialog classes
    $variables['body_classes'] .= ' ' . $theme;
    $variables['body_classes'] .= ' dialog jquery-ui-filter-dialog';
    if (empty($features['page-regions'])) {
      $variables['body_classes'] .= ' jquery-ui-filter-dialog-no-regions';
    }

    // Remove sidebar classes
    $variables['body_classes'] = preg_replace('/\\s*\\w+-sidebar\\s*/', ' ', $variables['body_classes']);
    $variables['body_classes'] = preg_replace('/\\s*sidebar-\\w+\\s*/', ' ', $variables['body_classes']);
  }
}