I have a sub-theme which implements subtheme_preprocess_region(), and in there I add some classes to the classes array. However, these classes are not added to my region markup. I think it's because Zen does all it's stuff before my sub-theme adds these classes.

It appears that the functions get executed in the following order:

zen_preprocess
zen_preprocess_region
zen_process (this is where the classes array get joined)
subtheme_preprocess
subtheme_preprocess_region (this is where I'm adding the classes)

Based on how the same thing works for blocks, I would expect that the subtheme preprocess functions would execute before zen_process. Here's the order the block functions are executed:

zen_preprocess
zen_preprocess_block
subtheme_preprocess
subtheme_preprocess_block
zen_process
zen_process_block

Am I missing something? Is this by design, or should the subtheme region functions be called before zen_process?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

maartenverbaarschot’s picture

Title: Adding region classes » Can't add classes in subtheme_preprocess_region()

I experienced this too. I don't think it's by design, as it does work as expected with node and block preprocessors. (Marked #1181184: zen_process() is called before mysubtheme_preprocess_region() as a duplicate of this issue)

barraponto’s picture

Title: Can't add classes in subtheme_preprocess_region() » zen_process is called too early
Priority: Normal » Major

This is my first patch regarding the theme registry, so beware.

I noticed the process functions get called again later, when we loop through existing hook, so I guess we can safely remove from the array added by default to theme_region. Thus, when it gets added, all of the preprocess functions are already added.

I have changed the priority of this bug to major, since it breaks a d7 functionality Zen backports.

barraponto’s picture

barraponto’s picture

Status: Active » Needs review

this is one of those days.

JohnAlbin’s picture

Component: PHP code » layout.css
Status: Needs review » Needs work
mvdve’s picture

Issue summary: View changes

I experience the same issue (i think... still not sure what is happening).
The preprocess function of my panels layout does not get run all the time. There is a static variable set within this function (with panels everywhere) and it is not always set. In this case, the complete preprocess function of the panels layout is not activated.

JohnAlbin’s picture

Status: Needs work » Closed (works as designed)