I have multiple customized blocks with different content (eg. Advertisements, Quotes, Youtube videos, etc..)


Question: How can I automatically assign these blocks from different regions for example:

block--apple to sidebar_first region
block--pineapple to sidebar_right region
block--orange to region--myCustomRegion

Is there a theme function that automatically fills my target REGIONs with these BLOCKs without using the dashboard. I just want all blocks is ready when my theme is installed. Thank you very much in advance.

1 Answer 1


There is no theming function to do this, and there cannot be, because assigning block to regions is more logic than theming matter. So you should do it at module level.

When you are implementing hook_block_info(), you can specify default region, like this:

$blocks['example_empty'] = array(
  'info' => t('Example: empty block'),
  'status' => TRUE,
  'region' => 'sidebar_first',
  'visibility' => BLOCK_VISIBILITY_LISTED,
  'pages' => 'node/*',

You can also use hook_block_info_alter() to provide default regions for blocks not defined in your module.

See Examples for developers, block example for more details and samples.


Your Answer

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

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