0

I have the following snippet in a theme's page.tpl.php:

<div id="content-wrap" class="row">
          <?php print render($title_prefix); ?>
          <?php if ($title): ?><h1 class="page-title"><?php print $title; ?></h1><?php endif; ?>
          <?php print render($title_suffix); ?>
          <?php if (!empty($tabs['#primary'])): ?><div class="tabs-wrapper clearfix"><?php print render($tabs); ?></div><?php endif; ?>
          <?php print render($page['help']); ?>
          <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?>
          <?php print "**59**". render($page['content'])."**88**"; ?>
        </div>

The starred numbers in the last line for debugging. The output of render($page['content']) is something like the follwoing:

<div class="region region-content">
  <div id="block-system-main" class="block block-system">
.....

What I need to perform is programmatically change or add class name to <div class="region region-content">

1

You can do that in a module/theme by adding a region preprocess hook:

function MYTHEME_preprocess_region(&$vars) {
  if ($vars['region'] == 'content') {
    $vars['classes_array'][] = 'foo';
  }
}
| improve this answer | |
  • Do you mean template.php file? – SaidbakR Jun 18 '14 at 17:38
  • Yes - add that, replace MYTHEME with name of your theme, and clear the caches. Hopefully you should see the changes straight away – Clive Jun 18 '14 at 17:39
  • 1
    Thank you very much. I found another way to do this by modifying <div class="<?php print $classes; ?> foo"> in region.tpl.php. My theme contain this file, if it is not found in the theme we are able to overwrite it by copying it from modules/system/ and placing it the theme directory. – SaidbakR Jun 18 '14 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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