Issues with hook_preprocess

himerus - October 29, 2009 - 05:04
Project:Omega
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:himerus
Status:closed
Issue tags:alpha5
Description

I just found an issue while subtheming related to the code from the Studio theme & the hook_preprocess implementation that calls files from the preprocess directory.

Tested in a dev sandbox, this code seems to now work properly.

<?php
/**
* Implementation of hook_preprocess()
*
* This function checks to see if a hook has a preprocess file associated with
* it, and if so, loads it.
*
* @param $vars
* @param $hook
* @return Array
*/
function canvas_preprocess(&$vars, $hook) {
 
// Collect all information for the active theme.
 
$themes_active = array();
  global
$theme_info;

 
// If there is a base theme, collect the names of all themes that may have
  // preprocess files to load.
 
if($theme_info->base_theme) {
    global
$base_theme_info;
    foreach(
$base_theme_info as $base){
     
$themes_active[] = $base->name;
    }
  }

 
// Add the active theme to the list of themes that may have preprocess files.
 
$themes_active[] = $theme_info->name;

 
// Check all active themes for preprocess files that will need to be loaded.
 
foreach($themes_active as $name) {
    if(
is_file(drupal_get_path('theme', $name) . '/preprocess/preprocess-' . str_replace('_', '-', $hook) . '.inc')) {
      include(
drupal_get_path('theme', $name) . '/preprocess/preprocess-' . str_replace('_', '-', $hook) . '.inc');
    }
  }
}
?>

I will be testing this on my core development sandbox tomorrow, and patching if it works.
This was found causing issues in hook_preprocess node on a subtheme where it was only getting called once on pages with multiple nodes. The attributes being assigned by the default preprocess functionality in the Omega theme.

Solution was found here: http://cvs.drupal.org/viewvc.py/drupal/contributions/themes/studio/canvas/template.php?revision=1.3&view=markup

#1

himerus - October 29, 2009 - 16:58
Status:needs work» fixed

Will be fixed in alpha5

#2

System Message - November 12, 2009 - 17:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.