Add a new region to theme programmatically in Drupal

drupal-regions

/**
 * Implements hook_system_info_alter()
 * Adds a new "tray" region to the current theme
 */
function MODULE_system_info_alter(&$info, $file){
  global $custom_theme;    

  // If non-default theme configuration has been selected, set the custom theme.
  $custom_theme = isset ($theme) ? $theme : variable_get('theme_default', 'bartik');

  if ($file->name == $custom_theme){
    $info['regions'] = array_merge($info['regions'],  array('tray' => t('Tray')));
  } 
}
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