I'm using Drupal 7 with Boostrap Theme.

I put the main theme inside sites/all/themes/ And as a recommanded I put sub-theme in sites/my-site.com/themes/

It's working fine but my question is about preprocess hook.

The main theme using bootstrap_preprocess_region() to add some attributes to regions. In my subtheme, I want to alter attributes of a region already "hooked" by main theme.

So, in my sub-theme template.php file I did

$region = $variables['region'];
switch ($region) {
 case 'header':
 $variables['attributes_array']['id'] = 'main-header';

But there is no effect in my output ; main theme preprocess function is called after my subtheme preprocess function :( (I dumped string inside each preprocess to see which is called first)

Is that normal ? Is there a global workaround ?

2 Answers 2


EDIT : solution (can't answer myself before 8hours after posting)

Ok for those who're interested in the why :

It's a "side effect" of Twitter Bootstrap theme specific loader (_bootstrap_theme(), bootstrap_include ...)

To respect the correct order of hook processing, we have to keep the same filename as the main theme where hook is located in. (directories tree could change)

In my case, bootstrap_preprocess_region() was located in \sites\all\themes\bootstrap\theme\system\region.vars.php, so to overwrite it the mytheme_preprocess_region() should not be in my subtheme template.php file (=> breaking order of processing)

It should live in \sites\my-site.com\themes\mytheme\(opional folder)\(optional folder 2)\region.vars.php

Not explicitly written in TBS documentation I think ...

I hope this could help someone one day ! (:


The Drupal 7 Atomium base theme also has this mechanism and some other goodies.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.