Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a class to a Drupal 7 region?

I am trying to add a .clearfix class to my footer region in a Drupal 7. Is there a way to do this?

I am currently using the following to print my footer region:

<?php print render($page['footer']); ?>

Which outputs:

<div class="region region-footer">
   <div id="block-1>....</div>
   <div id="block-2>....</div>
</div>
like image 267
Heinen Creative Avatar asked Jul 20 '11 11:07

Heinen Creative


1 Answers

Here's the code snippet:

function MY_THEME_NAME_preprocess_region(&$variables, $hook) {
    if($variables['region'] == "MY_REGION_NAME"){
        $variables['classes_array'][] = 'MY_CLASS_NAME';
    }
}

Or if you'd rather insert the class into all of the regions:

function MY_THEME_NAME_preprocess_region(&$variables, $hook) {
    $variables['classes_array'][] = 'MY_CLASS_NAME';
}
like image 103
snufft Avatar answered Sep 27 '22 22:09

snufft