Last updated 26 December 2009. Created on 21 April 2008.
Edited by nightowl77, Sunshiney, webchick, Tom Ash. Log in to edit this page.

With this module you can set the visibility of your blocks programmatically, using one structured array. Instead of determining the block visibility by custom PHP code, this module provides a pre-defined script that uses a central configuration function bpv_config().

The visibility is set up in the module code in the config function, example:

function bpv_config($name) {
  $blocks = array(
    'user-0' => array(0, 'user* node*', '', ''),
    'comment-0' => array(1, '', 'story page', ''),
    'block-3' => array(0, 'news', '', ''), // custom block with id 3
  return $blocks[$name];

The key in the array is the ID of the block.

The first item in the array determines if the block should be displayed, for example:

  • 0: Display only on the given pages
  • 1: Display on all pages except the given pages

The second item gives you the (space separated) list of pages the visibility depends upon. The third item contains the triggering content types, while the last item is just a general purpose boolean; in general, you won't need to bother about it.

After adding your block to its region, you have to save its configuration file, so the custom php code can be inserted into the blocks table.

Module page:

Notes on the Snippets above:

$name is the array key. When the bpv.module calls to check a modules visibility it will use the blocks id (you can get this easily if you check the url of the configure link on a block) as the $name key.

Thus bpv_config($name) will return the row in the array with key $name.

Looking for support? Visit the forums, or join #drupal-support in IRC.