Experimental Project

This is a sandbox project, which contains experimental code for developer use only.

Block Options allows site administrators to define options that will appear
as checkboxes on block configuration pages.
Selected options will be available as css classes in the block.tpl.php template file

Features

  • Familiar interface for definition of options (Similar to CCK checkboxes)
  • Userfriendly interface for block administrators to apply special options/classes to blocks
  • Simplifies theming of "special" blocks
  • No coding in supported themes (eg Zen)

Requirements

There are no special requirements for this module

Known problems

The options keys must be valid as css classes

Configuration

1. After installation Go to Admin > Configuration > Block Options
2. Optionaly modify the title and description of the section that will appear in block's configuration page
3. Create some options
4. Create css classes that correspond to the options
5. To add a class/option to a block, simply visit that block's configuration page at Admin > Site Building > Blocks
6. Optionally (See list of themes supported) insert some code into your theme (see the methods below)

Modifying block.tpl.php

Block options are available in block templates as flattened array (strings separated with space) in the following variables

$classes

$block_options_classes

and as a keyed array in
$block_options

Sample use in Garland Theme block.tpl.php

<style>
.my-option-a {
  margin:10px;
}

.my-option-b {
  background-color: black;
  color: white;
}
</style>
<?php
/**
* Block Options usage:
* <?php print $block_options_classes; ?>

* Prints: my-option-a my-option-b
*/
?>
<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?> <?php print $block_options_classes; ?>">
<?php if (!empty($block->subject)): ?>
  <h2><?php print $block->subject ?></h2>
<?php endif;?>

  <div class="content">
<!-- Block Options usage: if (!empty($block_options['my-option-a']))    -->
<?php
/**
* Block Options usage:
* if (!empty($block_options['my-option-a']))
* Returns TRUE if option a was checked in the block configuration page
*/
?>

  <?php if (!empty($block_options['my-option-a'])): ?>
You have set option a for this block
  <?php endif;?>
  <?php print $block->content ?>
  </div>
</div>

List of themes supported (No coding necessary)

Other themes if possible upon request

Credits

Block Options was developed and is maintained by Nano IKT - Tom Øyvind Hogstad .

Similar projects

Block options was conceived because I needed a more user friendly way og doing what
Block Class (http://drupal.org/project/block_class)
is doing

Roadmap

Drupal 7 version will follow shortly

Maintainers for Block Options

  • sauce71 - 20 commits
    last: 19 weeks ago, first: 36 weeks ago

Issues for Block Options

To avoid duplicates, please search before submitting a new issue.
All issues
Bug reports