Style block based on configuration setting I'm writing a module for Drupal and a bespoke theme. The blocks of the modules either float to the left or the right of the region their in. Currently I do that by hard coding specific css styles, e.g. 

#block-myModuleName-myBlockName {float:left; background: red;}
#block-myModuleName-anotherBlockName {float:right; background: blue;}


I want to be able to set left/right (and maybe something else like background colour). So I've created an admin form that saves a persistent variable, such as variable_get('myBlockName-left', 0).

I can use that in the block content. I can wrap the content in a div that is based on the var such as &lt;div class="myModulesetToLeft"&gt;, but that will not include the title, and it's a bit messy because it's deeper into the DOM of the block.

Do I need to create a template file for blocks? But that code will need to know what block it is displaying, so that it can check the right variable to know which class to add to the block div.
I'd probably just use the Block Class module and assign a classes like block-left and block-right.


  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
  &lt;div class="block ..."&gt; element of a block. Hooray for more powerful
  block theming!