region.tpl.php

The region template in Adaptivetheme is a little different to most other themes. Instead of hard coding its markup Adaptivetheme generates it in adaptivetheme_process_region(), conditionally printing outer and inner wrappers. This allows the core theme to have just one region template instead of four. It achives this by not printing any markup in the actual template and instead uses variables.

Adativetheme supplied variables

  • $outer_prefix: Outer div with region classes.
  • $outer_suffix: Closing element.
  • $inner_prefix: Inner div with .region-inner and .clearfix classes.
  • $inner_suffix: Closing div.

The actual template is very simple:

<?php
if ($content) {
  print
$outer_prefix . $inner_prefix . $content . $inner_suffix . $outer_suffix;
}
?>

You can override this in your sub-theme with a standard region template suggestion if you prefer, or use your own themeName_process_region() function to control the markup.

For example you might want to override the region template for the Highlighted region, you can use a suggestion:

Template name: region--highlighted.tpl.php

Template file code:

<?php if ($content): ?>
  <div class="<?php print $classes; ?>">
    <div class="region-inner clearfix">
      <?php print $content; ?>
    </div>
  </div>
<?php endif; ?>

Or if you prefer to theme from process functions you can skip the additional template and just do this in themeName_process_region():

<?php
 
if ($vars['region'] === 'highlighted') {
   
$vars['outer_prefix'] = '<div class="' . $vars['classes'] . '">';
   
$vars['inner_prefix'] = '<div class="region-inner clearfix">';
   
$vars['inner_suffix'] = '</div>';
   
$vars['outer_suffix'] = '</div>';
  }
?>

Sidebar Region Template

You can use a singlular region--sidebar.tpl.php template suggestion to theme both sidebars simultaneously.

@see adaptivetheme_preprocess_region()
@see adaptivetheme_process_region()

Last updated 27th April, 2012 - 2:05pm