[development] hook_block can set properties (weight, enabled, etc.) for blocks

Nedjo Rogers nedjo at islandnet.com
Tue Jun 20 23:59:03 UTC 2006

A quick FYI for module authors. As of 4.7, we can set all block properties 
except theme in hook_block (instead of, previously, just 'content' and 
'subject'). This is a change that was part of the block region patch. So, 
for example, you can give your blocks an explicit weight, enable them, limit 
them to given pages, etc. Example:

$block = array('weight' => -6, 'enabled' => 1, 'region' => 'content', 
'subject' => t('Example'));
$block['content'] = t('This is an example');

These settings will be registered when the block is first loaded at 
admin/block, and from there can be changed manually via block 

Note that if you set a region that isn't available in a given theme, the 
block will be registered instead to that theme's default region (the first 
item in the _regions array). 

More information about the development mailing list