I've created a region preprocess function in my Zen sub theme, to add classes via $variables['classes_array'][].

This isn't working, because zen_process() is called right after Zen's own preprocess functions, instead of the ones in my sub theme.

I'm not sure how to fix this in Zen for a patch, but this is how I fixed it in my own theme for now:

<?php
/**
 * Implementation of HOOK_theme().
 */
function mysubtheme_theme(&$existing, $type, $theme, $path) {
  $hooks = zen_theme($existing, $type, $theme, $path);
  
  // Override preprocess function suggestions for regions so that zen_process() will be called last.
  $existing['region']['preprocess functions'] = array(
    'template_preprocess',
    'zen_preprocess',
    'zen_preprocess_region',
    'mysubtheme_preprocess',
    'mysubtheme_preprocess_region',
    'zen_process',
  );
  
  return $hooks;
}

/**
 * Preprocess variables for region.tpl.php.
 */
function mysubtheme_preprocess_region(&$variables) {
  // These regions need to be rendered as columns.
  if ($variables['region'] == 'content_bottom_first' || $variables['region'] == 'content_bottom_second') {
    $variables['classes_array'][] = 'column';
  }
}

Comments

maartenverbaarschot’s picture

Status: Active » Closed (duplicate)

Just found #1168324: zen_process is called too early
Marking this as a duplicate.