template_preprocess_page(&$variables)
Prepares variables for the page template.
Default template: page.html.twig.
See the page.html.twig template for the list of variables.
File
- core/includes/theme.inc, line 1346
- The theme system, which controls the output of Drupal.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | function template_preprocess_page(& $variables ) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); foreach (\Drupal::theme()->getActiveTheme()->getRegions() as $region ) { if (!isset( $variables [ 'page' ][ $region ])) { $variables [ 'page' ][ $region ] = array (); } } $variables [ 'base_path' ] = base_path(); $variables [ 'front_page' ] = \Drupal::url( '<front>' ); $variables [ 'language' ] = $language_interface ; // 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 ( $node = \Drupal::routeMatch()->getParameter( 'node' )) { $variables [ 'node' ] = $node ; } } |
Please login to continue.