7

How can I add a block to a region using Drush?

I'm using Drupal 7.0 and Drush 4.3.

13

The Drush extras project has commands for administering blocks.

Short instructions (following their README.txt):

  1. Install this Drush add-on:

    drush dl drush_extras
    
  2. Determine desired module name and delta of block, and the desired region name and weight for adding the block:

    drush block-show
    
  3. Add the block to the region:

    drush block-configure --module=block_module --delta=block_delta \
      --region=region_name --weight=-12
    

More instructions via:

drush help block-show
drush help block-configure
drush help block-disable
-1

I think you maybe asking the wrong question here. I think your question might be - "how do I automate deployments to include blocks being placed in regions"?

In this case you have a few options, I would recommend:

  • Use panels and the page manager (currently on alpha 3)
  • Add blocks to a page layout and get this exactly how you what it. Views etc can also be added to the layout
  • Export the pages to features (current just hit beta 2 for drupal 7)
  • The feature can optionally have dependencies on other modules that may provide blocks for you module
  • On deploy, revert the feature to enable the dependent modules and place the blocks in the right spot on the panel layout

I prefer this approach as it keeps your entire site layout in code, thus making it able to be stored in version control, and of course deployable to your production web servers with little hassle. Roll back is also made easy.

  • 3
    "I think you maybe asking the wrong question here." NO, I think YOU misunderstood the question. :) He asked whether he can simply add a block to a certain region via Drush. Your answer didn't contain any information related to the question. – Sk8erPeter Aug 30 '13 at 18:08

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.