I am writing a module that will, using javascript, create a slide down container at the top of the page. (modelled on the login here http://xenforo.com/community/).

Rather than hardcode the content in this slide-down region, I'd rather just create a new block region, and let the user put whatever blocks into it he/she sees fit.

The thing is, this sort of thing would normally be done with the theme, not with a module. Is it possible to define a new block region using a module, and if so, how?

3 Answers 3


hook_system_info_alter is your friend.

 * Implements hook_system_info_alter()
 * Adds a new "tray" region to the current theme
function MODULE_system_info_alter(&$info, $file){
  global $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')));
  • Nice research, so you can disable a region
    – Codium
    Mar 30, 2013 at 17:20
  • This is great. It worked perfectly. I'm totally smiling looking at code- thank you so much! :-)
    – cjm2671
    Apr 4, 2013 at 9:09
  • 1
    In the code snippet, it checks for isset($theme) when $theme is not anywhere else in the code. Is that a typo?
    – rooby
    Apr 21, 2013 at 11:07
  • I think the mistake is in the first line of the function. Instead of global $custom_theme; there should be global $theme;.
    – Temaruk
    Nov 6, 2013 at 17:36

Not possible. All regions are defined in .info file of theme and your theme templates must contain code which print content of region somewhere in a page.

  • 1
    As it turns out, not true! See the winning answer!
    – cjm2671
    Apr 4, 2013 at 9:08

There are 'blocks' and there are 'regions'. You can put blocks into regions. You don't need to know what regions someone has on a site in order to create a block, which is what I believe you're wanting to do.

In order to create a block, at a minimum you need to define what is listed in the drupal blocks listing, i.e. "My lovely block"; what happens to it if displayed, i.e. add my lovely javascript, output this html, etc. You can also add configuration options etc. depending on your particular requirements.

There are plenty of examples of block code throughout the core and contrib drupal modules so feel free to look up the code, also see:

http://drupal.org/project/examples http://api.drupal.org/api/drupal/modules!block!block.api.php/7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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