Block Class allows users to add classes to any block through the block's configuration interface. By adding a very short snippet of PHP to a theme's block.tpl.php file, classes can be added to the parent <div class="block ..."> element of a block. Hooray for more powerful block theming!

Installing the Drupal 7.x version

  1. Enable the module
  2. To add a class to a block, simply visit that block's configuration page at Administration > Structure > Blocks

Installing the Drupal 6.x version (6.x-1.3)

  1. Enable the module
  2. Add this snippet to your theme's block.tpl.php file (see detailed instructions below): <?php print block_class($block); ?>
  3. To add a class to a block, simply visit that block's configuration page at Administration > Site Building > Blocks

How to add the PHP snippet (7.x-1.x, 6.x-1.3 or lower)

Here's the first line of the Garland theme's block.tpl.php prior to adding the code:

<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?>">

And here's what the code should look like after adding the snippet:

<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?> <?php print block_class($block); ?>">

IMPORTANT: Remember to separate the PHP snippet from the existing markup with a single space. If you don't add the space, your CSS classes could run together like this: block-modulecustomclass instead of block-module customclass.

Installing the Drupal 6.x dev version

  1. Enable the module
  2. Add this snippet to your theme's block.tpl.php file (see detailed instructions below): <?php print $block_classes; ?>
  3. To add a class to a block, simply visit that block's configuration page at Administration > Site Building > Blocks

How to add the PHP snippet (6.x-dev, 6.x-1.4 or greater)

Here's the first line of the Garland theme's block.tpl.php prior to adding the code:

<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?>">

And here's what the code should look like after adding the snippet:

<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?> <?php print $block_classes; ?>">

IMPORTANT: Remember to separate the PHP snippet from the existing markup with a single space. If you don't add the space, your CSS classes could run together like this: block-modulecustomclass instead of block-module customclass.

Credits

Development of this module is sponsored by Four Kitchens.

Downloads

Recommended releases

Version Downloads Date Links
7.x-2.0 tar.gz (9.2 KB) | zip (10.16 KB) 2013-Mar-07 Notes
6.x-1.4 tar.gz (9.32 KB) | zip (10.31 KB) 2012-Feb-23 Notes

Other releases

Version Downloads Date Links
7.x-1.2 tar.gz (8.67 KB) | zip (9.58 KB) 2012-Oct-03 Notes

Development releases

Project Information


Maintainers for Block Class

  • DYdave - 9 commits
    last: 5 weeks ago, first: 11 weeks ago
  • berenddeboer - 14 commits
    last: 33 weeks ago, first: 1 year ago
  • Todd Nienkerk - 36 commits
    last: 1 year ago, first: 5 years ago
  • elliotttf - 1 commit
    last: 2 years ago, first: 2 years ago

Issues for Block Class

To avoid duplicates, please search before submitting a new issue.
All issues
Bug reports
Statistics (2 years)
New issues
Open bugs
Participants
nobody click here