Install

Works with Drupal: 7.x

Using Composer to manage Drupal site dependencies

Downloads

Download tar.gz 10.85 KB
MD5: 28f80cf29a4ef6f9907d2ae0cfbb6025
SHA-1: 12680de73051ab602aa8dc5a9776af779f35b497
SHA-256: c4316143d5391778b25d6164112485e37e536fc00b53d560e4425849048091f6
Download zip 12.38 KB
MD5: 7fb7a6d7b9d7615019483e2ba65d9d1e
SHA-1: b5ead5ca9210cde5f78d44c1deb7ae292d3bdb67
SHA-256: 70caccc93611b2a47182198c1896227b1390095c71bb1742250c6ba01ca6c151

Release notes

This module extends Drupal's block visibility settings, for ease of configuration and deployment.

Features

  • Allows PHP block visibility to be defined in code.
  • Allows theme specific block visibility code.
  • Removes reliance on core php module and eval() for defining block visibility.

Usage

  1. Edit a block.
  2. Pick one or more of the applicable callback functions from the list provided.
  3. Implement the functions as follows:
/**
 * Block visibility callback for the search form block.
 *
 * @param object $block
 *   The block object.
 *
 * @return bool
 *   TRUE if the block should be displayed on the current page.
 */
function _search_form_block_visibility($block) {
  if ($block->theme == 'my_theme') {
    return !drupal_is_front_page();
  }
  return arg(0) == 'node' && is_numeric(arg(1));
}

Note that if multiple callbacks have been implemented for a block, the most specific match will always be used.

Possible extensions

  • Allow users to specify their own function names for each block.
  • Create a hook which can be implemented by one or more modules to determine block visibility (similar to hook_file_download()).
  • Create an info hook which can be used to specify callback names and override other block visibility settings, including user roles.

Similar projects

  • Features Extra: Allows exporting of block visibility settings for deployment, but still requires eval() and php code entry through the admin interface.
  • Block Page Visibility: Allows visibility options to be defined through a hook (D5/D6 only). This module provides similar functionality to hook_block_info() in Drupal 7 and doesn't provide php-based visibility.

Credits

Current maintainer: Mark Pavlitski

This project has been sponsored by:

  • Microserve
    Microserve is a Drupal web development agency based in Bristol, UK, specialising in Drupal Development, Drupal Training, Hosting and Peer Reviews.
Created by: markpavlitski
Created on: 8 May 2013 at 09:12 UTC
Last updated: 14 Jan 2014 at 10:33 UTC
New features
Bug fixes
Unsupported

Other releases