From 0fad01088ce03aa3f5ecf0211726492b78314934 Mon Sep 17 00:00:00 2001 From: JohnAlbin Date: Sun, 27 Nov 2011 16:34:47 +0800 Subject: [PATCH] Make sure maintenance_page.tpl gets all the same variables as html.tpl --- STARTERKIT/template.php | 18 ++++++++++++++++++ template.php | 46 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/STARTERKIT/template.php b/STARTERKIT/template.php index b2aded9..8130d23 100644 --- a/STARTERKIT/template.php +++ b/STARTERKIT/template.php @@ -103,6 +103,24 @@ /** + * Override or insert variables into the maintenance page template. + * + * @param $variables + * An array of variables to pass to the theme template. + * @param $hook + * The name of the template being rendered ("maintenance_page" in this case.) + */ +/* -- Delete this line if you want to use this function +function STARTERKIT_preprocess_maintenance_page(&$variables, $hook) { + // When a variable is manipulated or added in preprocess_html or + // preprocess_page, that same work is probably needed for the maintenance page + // as well, so we can just re-use those functions to do that work here. + STARTERKIT_preprocess_html($variables, $hook); + STARTERKIT_preprocess_page($variables, $hook); +} +// */ + +/** * Override or insert variables into the html templates. * * @param $variables diff --git a/template.php b/template.php index 62b5291..fcadaae 100644 --- a/template.php +++ b/template.php @@ -164,7 +164,9 @@ function zen_add_conditional_styles() { * @param $variables * An array of variables to pass to the theme template. * @param $hook - * The name of the template being rendered ("html" in this case.) + * The name of the template being rendered. This is usually "html", but can + * also be "maintenance_page" since zen_preprocess_maintenance_page() calls + * this function to have consistent variables. */ function zen_preprocess_html(&$variables, $hook) { // If the user is silly and enables Zen as the theme, add some styles. @@ -178,7 +180,7 @@ function zen_preprocess_html(&$variables, $hook) { // Classes for body element. Allows advanced theming based on context // (home page, node of certain type, etc.) - if (!$variables['is_front']) { + if (!$variables['is_front'] && $hook == 'html') { // Add unique class for each page. $path = drupal_get_path_alias($_GET['q']); // Add unique class for each website section. @@ -197,18 +199,22 @@ function zen_preprocess_html(&$variables, $hook) { $variables['classes_array'][] = 'with-wireframes'; // Optionally add the wireframes style. } // Store the menu item since it has some useful information. - $variables['menu_item'] = menu_get_item(); - switch ($variables['menu_item']['page_callback']) { - case 'views_page': - // Is this a Views page? - $variables['classes_array'][] = 'page-views'; - break; - case 'page_manager_page_execute': - case 'page_manager_node_view': - case 'page_manager_contact_site': - // Is this a Panels page? - $variables['classes_array'][] = 'page-panels'; - break; + if ($hook == 'html') { + $variables['menu_item'] = menu_get_item(); + if ($variables['menu_item']) { + switch ($variables['menu_item']['page_callback']) { + case 'views_page': + // Is this a Views page? + $variables['classes_array'][] = 'page-views'; + break; + case 'page_manager_page_execute': + case 'page_manager_node_view': + case 'page_manager_contact_site': + // Is this a Panels page? + $variables['classes_array'][] = 'page-panels'; + break; + } + } } $variables['jump_link_target'] = theme_get_setting('zen_jump_link_target'); $variables['jump_link_text'] = theme_get_setting('zen_jump_link_text'); @@ -254,6 +260,18 @@ function zen_preprocess_maintenance_page(&$variables, $hook) { } /** + * Override or insert variables into the maintenance page template. + * + * @param $variables + * An array of variables to pass to the theme template. + * @param $hook + * The name of the template being rendered ("maintenance_page" in this case.) + */ +function zen_process_maintenance_page(&$variables, $hook) { + zen_process_html($variables, $hook); +} + +/** * Override or insert variables into the node templates. * * @param $variables -- 1.7.4.1