3

I want to disable a region, to not show blocks in this region to an specific page. I want this because, I have several blocks (more than 20) so in this case is necessary enter to each block, and configure in what page or pages must not be showed. Well I can do that, I just want to know if exist some way to make this task in a more practical way, or in a programmatically way.

I am using Drupal 6.

1

The quickest way is to unset the region you want hidden in your theme's template.php. For example:

function YOUR_THEME_preprocess_page(&$vars) {
  if (drupal_is_front_page())
    unset($vars['left']);
}
  • thank you! I will change the content of IF to something to get path alias (drupal_get_path_alias) to hide block in specific places. Also I must say that is necessary clean chache to view results (at least to me). very thanks. – cigotete Aug 11 '11 at 2:20
  • this code actually loads the blocks, but then unsets them. – Capi Etheriel Aug 11 '11 at 3:11
  • True. Another solution I came across was style="display: none"... Unfortunately D6's modular system is lacking when it comes to blocks. To programmatically disable blocks that are configured to show up in a specific region, think hook_boot(), register_shutdown_function() and a bit of SQL over {blocks}. – Jan Tomka Aug 11 '11 at 4:11
5

The context module is a very handy way to control blocks on a site which uses them extensively. It allows you to define contexts which show and hide blocks. It will stop the blocks from even being loaded so will help performance.

It makes it much easier to define where and when the blocks appear. Rather than defining things per block you define what blocks appear per context.

This video seems to explain things well.

2

You may want to try the Region Visibility module.

They say:

This module allows privileged users to set role or page specific visibility settings for regions, similar to the block visibility settings in Drupal core.

I didn't try it out myself, but it seems useful.

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.