Show drupal status messages in omega theme region

I had to include the render of the drupal status messages ($messages) in the “region–content.tpl.php” template.

$messages is not available in regions (its a page variable, not a region variable). For Omega it is also a zone variable,

by default it is available in “zone–content.tpl.php”, to make it available for regions i had to add $messages via hook_region_process :

/**
 * Implements hook_process_region().
 */
function mytheme_process_region(&$vars) {
  $theme = alpha_get_theme();
  if ($vars['elements']['#region'] == 'content') {
    $vars['messages'] = $theme->page['messages'];
  }  
}

Than create a “region–content.tpl.php” which will contain :

<div<?php print $attributes; ?>>
  <div<?php print $content_attributes; ?>>
    <?php if ($messages): ?>
      <div id="messages" class=""><?php print $messages; ?></div>
    <?php endif; ?>
    <a id="main-content"></a>
    <?php print render($title_prefix); ?>
    <?php if ($title): ?>
    <?php if ($title_hidden): ?><div class="element-invisible"><?php endif; ?>
    <h1 class="title" id="page-title"><?php print $title; ?></h1>
    <?php if ($title_hidden): ?></div><?php endif; ?>
    <?php endif; ?>
    <?php print render($title_suffix); ?>
    <?php if ($tabs && !empty($tabs['#primary'])): ?><div class="tabs clearfix"><?php print render($tabs); ?></div><?php endif; ?>
    <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?>
    <?php print $content; ?>
    <?php if ($feed_icons): ?><div class="feed-icon clearfix"><?php print $feed_icons; ?></div><?php endif; ?>
  </div>
</div>

Hope this will be useful!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s