7 theme.inc template_preprocess_page(&$variables)
6 theme.inc template_preprocess_page(&$variables)
8 theme.inc template_preprocess_page(&$variables)

Prepares variables for the page template.

Default template: page.html.twig.

Most themes use their own copy of page.html.twig. The default is located inside "modules/system/page.html.twig". Look in there for the full list of variables.

1 call to template_preprocess_page()
template_preprocess_maintenance_page in core/includes/theme.inc
Prepares variables for maintenance page templates.

File

core/includes/theme.inc, line 1344
The theme system, which controls the output of Drupal.

Code

function template_preprocess_page(&$variables) {
  $language_interface = \Drupal::languageManager()->getCurrentLanguage();
  $site_config = \Drupal::config('system.site');

  // Move some variables to the top level for themer convenience and template cleanliness.
  $variables ['title'] = $variables ['page']['#title'];

  foreach (system_region_list(\Drupal::theme()->getActiveTheme()->getName()) as $region_key => $region_name) {
    if (!isset($variables ['page'][$region_key])) {
      $variables ['page'][$region_key] = array();
    }
  }

  $variables ['base_path'] = base_path();
  $variables ['front_page'] = \Drupal::url('<front>');
  $variables ['language'] = $language_interface;
  $variables ['logo'] = theme_get_setting('logo.url');
  $variables ['site_name'] = (theme_get_setting('features.name') ? SafeMarkup::checkPlain($site_config->get('name')) : '');
  $variables ['site_slogan'] = (theme_get_setting('features.slogan') ? Xss::filterAdmin($site_config->get('slogan')) : '');

  // An exception might be thrown.
  try {
    $variables ['is_front'] = \Drupal::service('path.matcher')->isFrontPage();
  }
  catch (Exception $e) {
    // If the database is not yet available, set default values for these
    // variables.
    $variables ['is_front'] = FALSE;
    $variables ['db_is_active'] = FALSE;
  }
  if (!defined('MAINTENANCE_MODE')) {
    $variables ['action_links'] = menu_get_local_actions();
    $variables ['tabs'] = menu_local_tabs();
  }
  else {
    $variables ['action_links'] = array();
    $variables ['tabs'] = array();
  }

  if ($node = \Drupal::routeMatch()->getParameter('node')) {
    $variables ['node'] = $node;
  }
}