Is there any reason that these blocks wouldn't be assigned to the regions specified? The only way I can get these to appear is to set them manually. Kinda defeats the purpose of defining a region in the first place.

function custom_module_block_info() {

  $blocks = array();
  $blocks['footer_touts'] = array(
    'info' => t('Footer Touts'),
    'status' => TRUE,
    'region' => 'footer',

  $blocks['carrousel'] = array(
    'info' => t('Carrousel'),
    'status' => TRUE,
    'region' => 'hp_content',
    'visibility' => BLOCK_VISIBILITY_LISTED,
    'pages' => '<front>',

  return $blocks;
  • Did you specify the region from the beginning/Can you reproduce this on a site that did not have this module installed before? It is possible that the value is not updated for existing blocks. That was long the case for the cache flag, for example. – Berdir Jun 2 '11 at 19:57
  • The region was specified from the beginning. I've tried adding the module on a fresh install and I get the same result. I've even tried disabling the module, clearing out all references to these blocks in the 'block' table and clearing the cache before re-enabling. I always get the same error. – Luis Jun 2 '11 at 20:50
  • If you look at the page listing in which region of a theme the blocks are visible, what do you see? Did you verify that those regions are present in the theme currently used? – kiamlaluno Jun 2 '11 at 21:22
  • 3
    It turns out that the status property isn't optional. When it is set to true, the blocks get assigned to the regions properly. – Luis Jun 3 '11 at 16:13

(Luis already answered eir own question, in the comments above, but I thought I'd add something here; all kudos to Luis though.)

The status property returned by a module's implementation of hook_block_info() must be TRUE. This is slightly unintuitive because when enabling blocks in the UI, one only has to choose the region—however, in doing so a block's status is also changed. Programmatically, we must set both status and region properties. (I'm not sure there would ever be any reason to set one and not the other.)

When doing this to an already-enabled module, it would seem that clearing the block cache (drush cc block) is not enough, nor is dis- and re-enabling the module; it must be uninstalled and reinstalled for the change to take effect (drush dre custom_module if you've got Devel).

Note also that Drush seems to get confused when doing this with a region that doesn't exist in the default theme (reporting that "The block Carrousel was assigned to the invalid region hp_content and has been disabled."). This is not true; the block is enabled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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