You are here

function panels_everywhere_theme_registry_alter in Panels Everywhere 6

Implementation of hook_theme_registry_alter()

This is the magic of this module, which allows us to completely override how pages are output.

File

./panels_everywhere.module, line 101
panels_everywhere.module

Code

function panels_everywhere_theme_registry_alter(&$registry) {
  if (!panels_everywhere_should_override_theme()) {
    return;
  }

  // Test to see if we should exclude the administrative theme.
  if (!variable_get('panels_everywhere_site_template_enabled_admin', FALSE)) {
    global $theme;
    $admin_theme = variable_get('admin_theme', '0');
    if ($admin_theme && $admin_theme == $theme) {
      return;
    }
  }
  $registry['original page'] = $registry['page'];

  // If we've been set to override the page template, we completely override it:
  $registry['page']['template'] = 'page';
  $registry['page']['type'] = 'module';
  $registry['page']['path'] = drupal_get_path('module', 'panels_everywhere') . '/theme';
  $registry['page']['theme path'] = $registry['page']['path'];
  $registry['page']['theme paths'] = array(
    drupal_get_path('module', 'system'),
    $registry['page']['path'],
  );
  $registry['page']['preprocess functions'] = array(
    'panels_everywhere_page_preprocess',
    'template_preprocess',
    'panels_everywhere_page_preprocess_elements',
  );

  // Let modules continue to do their thing
  foreach (module_implements('preprocess') as $module) {
    $registry['page']['preprocess functions'][] = $module . '_preprocess';
  }
  foreach (module_implements('preprocess_page') as $module) {
    if ($module != 'ctools') {
      $registry['page']['preprocess functions'][] = $module . '_preprocess_page';
    }
  }

  // CTools wants to be last
  $registry['page']['preprocess functions'][] = 'ctools_preprocess_page';
}