Pages

Tuesday 15 May 2012

How to change drupal block theme

Are you looking to change Drupal Block theme? Dont worry. Here is the way you can do that.
You need one module and that is Block Theme. Download and install this module. No need to set any user permissions for this module.
After installation go to configure it at this URL /admin/settings/blocktheme
In Custom block template textbox enter following and save configuration.
myblock|Some name
Where the first name is the machine-readable name of your template which may contain only
alphanumerical characters, -, or _ . The second name is the user-friendly name that appears
in the selectionbox on the block edit form.
After this save configuration.
If your theme already has block.tpl.php then make a copy of it an rename it as “blocktheme-myblock.tpl.php”.
If block.tpl.php file does not exist in your theme (Yes, some themes do not have block.tpl.php) directory copy code below and name it as “block.tpl.php” also make one more copy of this code below and rename it as “blocktheme-myblock.tpl.php”. This blockthem-myblock.tpl.php is the theme file applied for the block you select and block.tpl.php will be applied for remaining blocks.
Code.
01<?php
02// $Id: block.tpl.php,v 1.3 2007/08/07 08:39:36 goba Exp $
03?>
04<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?>">
05
06<?php if (!empty($block->subject)): ?>
07  <h2><?php print $block->subject ?></h2>
08<?php endif;?>
09
10  <div class="content"><?php print $block->content ?></div>
11</div>
Thats it.
Now go to /admin/build/block and configure any block you want to apply a theme to. On clicking a Configure link you will find one more section “Block Theme”. Select a theme from dropdown and Save block.
IMP: Do not forget to clear cached data from “/admin/settings/performance”.
Comments/Suggestions are welcome.

1 comment: