diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 681349f6b7fb9e22a42287631c7d9c74af18cedc..68b4e91415e5e77a1b77432fb225a4929d29d950 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,7 @@ Zen 6.x-1.x-dev * Upgrading to Drupal 6. Not yet complete. + #249532: Allow subthemes to have preprocess hooks without tpl files #223518: Option to show page title in breadcrumbs #253249: zen_id_safe fails when first character is extended latin #251632: Make the closure region more useful diff --git a/STARTERKIT/template.php b/STARTERKIT/template.php index e7c43a3c2887d1a5b1918477db2fe76588f9678e..ce32d0e5b5725d7e61eaada726ce96354066aa6e 100644 --- a/STARTERKIT/template.php +++ b/STARTERKIT/template.php @@ -48,6 +48,13 @@ if (theme_get_setting('STARTERKIT_fixed')) { // */ +/** + * Implementation of HOOK_theme(). + */ +function STARTERKIT_theme(&$existing, $type, $theme, $path) { + return zen_theme($existing, $type, $theme, $path); +} + /** * Override or insert PHPTemplate variables into all templates. * @@ -58,9 +65,6 @@ if (theme_get_setting('STARTERKIT_fixed')) { */ /* -- Delete this line if you want to use this function function STARTERKIT_preprocess(&$vars, $hook) { - // First run Zen's preprocess function. - phptemplate_preprocess($vars); - $vars['sample_variable'] = t('Lorem ipsum.'); } // */ @@ -75,9 +79,6 @@ function STARTERKIT_preprocess(&$vars, $hook) { */ /* -- Delete this line if you want to use this function function STARTERKIT_preprocess_page(&$vars, $hook) { - // First run Zen's preprocess function. - phptemplate_preprocess_page($vars); - $vars['sample_variable'] = t('Lorem ipsum.'); } // */ @@ -92,9 +93,6 @@ function STARTERKIT_preprocess_page(&$vars, $hook) { */ /* -- Delete this line if you want to use this function function STARTERKIT_preprocess_node(&$vars, $hook) { - // First run Zen's preprocess function. - phptemplate_preprocess_node($vars); - $vars['sample_variable'] = t('Lorem ipsum.'); } // */ @@ -109,9 +107,6 @@ function STARTERKIT_preprocess_node(&$vars, $hook) { */ /* -- Delete this line if you want to use this function function STARTERKIT_preprocess_comment(&$vars, $hook) { - // First run Zen's preprocess function. - phptemplate_preprocess_comment($vars); - $vars['sample_variable'] = t('Lorem ipsum.'); } // */ @@ -126,9 +121,6 @@ function STARTERKIT_preprocess_comment(&$vars, $hook) { */ /* -- Delete this line if you want to use this function function STARTERKIT_preprocess_block(&$vars, $hook) { - // First run Zen's preprocess function. - phptemplate_preprocess_block($vars); - $vars['sample_variable'] = t('Lorem ipsum.'); } // */ diff --git a/zen/template.php b/zen/template.php index 03212839e9b85d9b3a7f352624b053be38ef1711..2fff2fc7a878279b42b969557e5f28faf00663a9 100644 --- a/zen/template.php +++ b/zen/template.php @@ -94,7 +94,7 @@ function zen_breadcrumb($breadcrumb) { * @param $hook * The name of the theme function being called (name of the .tpl.php file.) */ -function phptemplate_preprocess(&$vars, $hook) { +function zen_preprocess(&$vars, $hook) { global $user; // Set a new $is_admin variable. This is determined by looking at the @@ -116,7 +116,7 @@ function phptemplate_preprocess(&$vars, $hook) { * @param $hook * The name of the theme function being called ("page" in this case.) */ -function phptemplate_preprocess_page(&$vars, $hook) { +function zen_preprocess_page(&$vars, $hook) { global $theme; // These next lines add additional CSS files and redefine @@ -190,7 +190,7 @@ function phptemplate_preprocess_page(&$vars, $hook) { * @param $hook * The name of the theme function being called ("node" in this case.) */ -function phptemplate_preprocess_node(&$vars, $hook) { +function zen_preprocess_node(&$vars, $hook) { global $user; // Special classes for nodes @@ -226,7 +226,7 @@ function phptemplate_preprocess_node(&$vars, $hook) { * @param $hook * The name of the theme function being called ("comment" in this case.) */ -function phptemplate_preprocess_comment(&$vars, $hook) { +function zen_preprocess_comment(&$vars, $hook) { global $user; // We load the node object that the current comment is attached to @@ -277,7 +277,7 @@ function phptemplate_preprocess_comment(&$vars, $hook) { * @param $hook * The name of the theme function being called ("block" in this case.) */ -function phptemplate_preprocess_block(&$vars, $hook) { +function zen_preprocess_block(&$vars, $hook) { $block = $vars['block']; // Special classes for blocks @@ -392,3 +392,43 @@ function path_to_zentheme() { } return $theme_path; } + +/** + * Implementation of HOOK_theme(). + * + * The Zen base theme uses this function as a work-around for a bug in Drupal + * 6.0-6.2: #252430 (Allow BASETHEME_ prefix in preprocessor function names). + * + * Sub-themes Also use this function by calling it from their HOOK_theme() in + * order to get around a design limitation in Drupal 6: #249532 (Allow subthemes + * to have preprocess hooks without tpl files.) + * + * @param $existing + * An array of existing implementations that may be used for override purposes. + * @param $type + * What 'type' is being processed. + * @param $theme + * The actual name of theme that is being being checked. + * @param $path + * The directory path of the theme or module, so that it doesn't need to be looked up. + */ +function zen_theme(&$existing, $type, $theme, $path) { + // Inspect the preprocess functions for each of Zen's tpl files. + $default_hooks = array('page', 'node', 'comment', 'block'); + foreach ($default_hooks AS $hook) { + // Each theme has two possible preprocess functions that can act on a hook. + $functions = array( + $theme . '_preprocess', + $theme . '_preprocess_' . $hook, + ); + foreach ($functions AS $key => $function) { + // Add any functions that are not already in the registry. + if (function_exists($function) && !in_array($function, $existing[$hook]['preprocess functions'])) { + // We add the preprocess function to the end of the existing list. + $existing[$hook]['preprocess functions'][] = $function; + } + } + } + // Since we modify the $existing cache directly, return nothing. + return array(); +} diff --git a/zen_classic/template.php b/zen_classic/template.php index 1c7efffbe0263b7b2e859b78cf45edf6f8515036..4cafcad030f884f6e938774e6616b693f0a116ac 100644 --- a/zen_classic/template.php +++ b/zen_classic/template.php @@ -46,6 +46,13 @@ if (theme_get_setting('zen_classic_fixed')) { } +/** + * Implementation of HOOK_theme(). + */ +function zen_classic_theme(&$existing, $type, $theme, $path) { + return zen_theme($existing, $type, $theme, $path); +} + /** * Override or insert PHPTemplate variables into all templates. * @@ -56,9 +63,6 @@ if (theme_get_setting('zen_classic_fixed')) { */ /* -- Delete this line if you want to use this function function zen_classic_preprocess(&$vars, $hook) { - // First run Zen's preprocess function. - phptemplate_preprocess($vars); - $vars['sample_variable'] = t('Lorem ipsum.'); } // */ @@ -73,9 +77,6 @@ function zen_classic_preprocess(&$vars, $hook) { */ /* -- Delete this line if you want to use this function function zen_classic_preprocess_page(&$vars, $hook) { - // First run Zen's preprocess function. - phptemplate_preprocess_page($vars); - $vars['sample_variable'] = t('Lorem ipsum.'); } // */ @@ -90,9 +91,6 @@ function zen_classic_preprocess_page(&$vars, $hook) { */ /* -- Delete this line if you want to use this function function zen_classic_preprocess_node(&$vars, $hook) { - // First run Zen's preprocess function. - phptemplate_preprocess_node($vars); - $vars['sample_variable'] = t('Lorem ipsum.'); } // */ @@ -107,9 +105,6 @@ function zen_classic_preprocess_node(&$vars, $hook) { */ /* -- Delete this line if you want to use this function function zen_classic_preprocess_comment(&$vars, $hook) { - // First run Zen's preprocess function. - phptemplate_preprocess_comment($vars); - $vars['sample_variable'] = t('Lorem ipsum.'); } // */ @@ -124,9 +119,6 @@ function zen_classic_preprocess_comment(&$vars, $hook) { */ /* -- Delete this line if you want to use this function function zen_classic_preprocess_block(&$vars, $hook) { - // First run Zen's preprocess function. - phptemplate_preprocess_block($vars); - $vars['sample_variable'] = t('Lorem ipsum.'); } // */