My client wants to turn on/off the whole region for block from the drupal menu. Is there some module that can do that?

Right now he must move the all six blocks from that region to disabled area and then he needs to find them and rearange when he want them back and it is not very efficient.

  • Any idea how can this be solved. Do I nned to create my own module for that? Is something available already? maybe some group block turn on/off module?
    – Derfder
    Dec 7, 2012 at 14:38

3 Answers 3


I don't have a single great suggestions. Here are a few things that come to mind.

  1. Wrap all the blocks in a single block. This way you could make a few "block groups".
  2. Just don't use the block system. It's not very good. My personal favourite block handling mechanism is Panels (Everywhere) and Page manager
  3. Panels Everywhere is capable of killing the entire block system. A peek into it's codebase could probably reveal how to do it on a region by region basis.

If you want to do this before the blocks are rendered, then hook_block_list_alter() is your friend.

 * Implements hook_block_list_alter()
 * Hides the right sidebar on some pages.
function THEME_NAME_block_list_alter(&$blocks) {
  if (!$fancy_condition) {

  // Go through all blocks, and hide those in the 'sidebar_second' region.
  foreach ($blocks as $i => $block) {
    if ('sidebar_second' === $block->region) {
      // Hide this block.

Note: Interestingly, this hook seems to work no matter if you have it in your theme or in a module. (Please correct me if I'm wrong)

The $fancy_condition is obviously a placeholder.

In your case, you want to do this based on a setting. Maybe you can provide an administration form somewhere, where this setting can be toggled. Or you could add an option to the theme settings.


There is a sandbox D7 Port of the D6 module Region Visibility which allows you to set role or page specific visibility settings for regions.

It does only what it says - allows regions to be toggled off per-path. (and also per-role)

This is handy if you want to, eg,

  • toggle some pages to be super-wide and have no sidebars on a path-by-path basis.
  • toggle header and footer off to present a 'bare' display ... based on paths alone.

For anything more advanced, I suggest you upgrade soon to the 'context' module, with allows you to build full logical display conditions, like "if user is not admin and content-type is 'article' and path is under 'archive/' but not 'archive/index/' then hide sidebar-left"

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.