1

I'm building up a custom module which contains a few blocks. These blocks will always only appear either on the front page or on every other page, mutually exclusive.

I'd like to be able to pre-configure these blocks on install, but I'm not sure how to go about it. The documentation for hook_block_configure mentions an '#options' key, but has no details on the format of that info.

Can anyone get me pointed in the right direction here?

1 Answer 1

0

If you want to set the standard block options, you can do that in hook_block_info

e.g:

/**
 * Implements hook_block_info
 */
function MODULE_block_info() {

  $blocks = array();

  // Assign block to front page, sidebar_first region by default
  $blocks['my_front_page_block'] = array(
    'info' => t('Front page block'),
    'status' => 1,
    'region' => 'sidebar_first',
    'visibility' => BLOCK_VISIBILITY_LISTED,
    'pages' => '<front>'
  );

  return $blocks;

}
1
  • 1
    I somehow missed that in the docs. My head is swimming learning Drupal, but its a pretty cool framework. Thanks! Commented May 16, 2014 at 16:00

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.