I think Omega is the best base theme out there, but I'm missing this feature that many other base theme have.
Sometimes I have to change the container background of some zone if a region is loaded.
Many themes load the class "sidebar-first" or "sidebars" if sidebars (or one in particular) is loaded.
It would be extremely powerful for styling add those classes in the body tag, or even better in the zone containing those regions.
A clear example :

<div id="zone-content" class="zone zone-content clearfix container-12 region-content-loaded region-sidebar-second-loaded">    
        <div class="grid-8 region region-content" id="region-content">...</div>
	<aside class="grid-4 region region-sidebar-second" id="region-sidebar-second">...</aside>
</div>

Other possibility is to exclude the region set as "primary".

Anyone can help me to achieve this behavior?
Thanks in advance.

Comments

cellar door’s picture

I just ran into the same thing with a custom theme I'm creating. I don't know if we really want to add this into the core as with the UI it's easy to change the name of your sidebar regions etc. If you want something like this though put the following in your template.php and adapt accordingly to place a bodyclass based on region.

 function YOURTHEMENAME_alpha_preprocess_html(&$vars) {
  $theme = alpha_get_theme();
  if ($theme->regions['REGIONNAME']) {
      $vars['attributes_array']['class'][] = 'REGIONNAME';
  }
 }

Enjoy!

elgandoz’s picture

Status: Active » Closed (fixed)

That's exactly what I was looking for! It adds the class REGIONAME to the body if loaded.
Many thanks.

elgandoz’s picture

Status: Closed (fixed) » Needs work

I was too fast. Using the function above, the values are get from the theme settings. This causes the region class loads on every page.
It could be useful in addiction to Delta module, but for a simple stuff like this I (possibly) don't want depend on an other module.
My goal is to load the region class only in the pages where the region is rendered, that is when there are no active blocks.

elgandoz’s picture

Status: Needs work » Closed (fixed)

I had to change the hook.
Ex. for "Sidebar Second" region

function YOURTHEMENAME_alpha_preprocess_page(&$vars) {
  if (isset($vars['page']['content']['content']['sidebar_second'])) {
      $vars['attributes_array']['class'][] = 'sidebar-second';
  }
}
vegantriathlete’s picture

Here is a more complete snippet. Also, note that the snippet in #4 has preprocess_page instead of preprocess_html.