Index: STARTERKIT/template.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/themes/zen/STARTERKIT/template.php,v retrieving revision 1.9 diff -u -p -r1.9 template.php --- STARTERKIT/template.php 21 Apr 2008 17:01:54 -0000 1.9 +++ STARTERKIT/template.php 21 Apr 2008 22:28:46 -0000 @@ -60,6 +60,7 @@ if (theme_get_setting('STARTERKIT_fixed' function STARTERKIT_preprocess(&$vars, $hook) { // First run Zen's preprocess function. phptemplate_preprocess($vars); + zen_parent_preprocess($vars, 'STARTERKIT'); $vars['sample_variable'] = t('Lorem ipsum.'); } @@ -75,6 +76,7 @@ function STARTERKIT_preprocess(&$vars, $ function STARTERKIT_preprocess_page(&$vars) { // First run Zen's preprocess function. phptemplate_preprocess_page($vars); + zen_parent_preprocess($vars, 'STARTERKIT', 'page'); $vars['sample_variable'] = t('Lorem ipsum.'); } @@ -90,6 +92,7 @@ function STARTERKIT_preprocess_page(&$va function STARTERKIT_preprocess_node(&$vars) { // First run Zen's preprocess function. phptemplate_preprocess_node($vars); + zen_parent_preprocess($vars, 'STARTERKIT', 'node'); $vars['sample_variable'] = t('Lorem ipsum.'); } @@ -105,6 +108,7 @@ function STARTERKIT_preprocess_node(&$va function STARTERKIT_preprocess_comment(&$vars) { // First run Zen's preprocess function. phptemplate_preprocess_comment($vars); + zen_parent_preprocess($vars, 'STARTERKIT', 'comment'); $vars['sample_variable'] = t('Lorem ipsum.'); } @@ -120,6 +124,7 @@ function STARTERKIT_preprocess_comment(& function STARTERKIT_preprocess_block(&$vars) { // First run Zen's preprocess function. phptemplate_preprocess_block($vars); + zen_parent_preprocess($vars, 'STARTERKIT', 'block'); $vars['sample_variable'] = t('Lorem ipsum.'); } Index: zen/template.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/themes/zen/zen/template.php,v retrieving revision 1.13 diff -u -p -r1.13 template.php --- zen/template.php 21 Apr 2008 17:03:03 -0000 1.13 +++ zen/template.php 21 Apr 2008 22:28:46 -0000 @@ -373,3 +373,40 @@ function path_to_zentheme() { } return $theme_path; } + +/** + * Call a parent theme's preprocess function. + * + * By default, a sub-theme's preprocess function will be called in place of the + * parent theme's, rather than in addition to. By calling this function as the + * first line of a preprocess function, you can easily make the effect additive. + * + * @param $vars + * The array of template variables. + * @param string $theme + * The name of the theme that is calling this function. + * @param string $hook + * The hook that we are preprocessing. + */ +function zen_parent_preprocess(&$vars, $theme, $hook = NULL) { + + static $called = array(); + + $themes = list_themes(); + + if (!empty($theme[$theme]->base_theme)) { + // If no hook is specified, then we're climbing the generic preprocess chain. + if (empty($hook)) { + $function = $theme[$theme]->base_theme . '_preprocess'; + } + else { + $function = $theme[$theme]->base_theme . '_preprocess_' . $hook; + } + + // Call the parent theme if possible. + if (function_exists($function) && empty($called[$function])) { + $function($vars); + $called[$function] = TRUE; + } + } +}