
How to assign custom CSS class for individual block in Drupal |
|
| CMS - Content Management Systems |
| Thursday, 15 April 2010 10:56 |
|
This might be usefull for anyone who wants to improve their Drupal theme. By default it is really hard to assign the class or id to individual blocks. The solution is here http://drupal.org/project/block_class This is a great module, when you enable it you can see a special box under each block, where you can add a name of that class. But you neeed to overrode the default block.tpl file. Add this snippet to your theme's block.tpl.php file (see detailed instructions below): Here is a sample of my code in block.tpl file <?php // $Id: block.tpl.php,v 1.3 2007/08/07 08:39:36 goba Exp $ ?> <div id="block-module; ?>-delta; ?> "> <h2><?php print $block->subject; ?></h2> <div><?php print $block->content; ?></div> </div> As you can see this snipet <?php print block_class($block); ?> is adding css to the code. p.s. 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. |
Dragon Naturally Speaking I complete...
Newly Updated Bookmarking Sites 2012 ...
Great thanks, looks like i have alot ...
I totally agree that the taxonomy suc...
Hey There. DId you resolve your p...
yes you are right, this company is ho...
For years and years now I have been r...
Thanks for posting this great article...
I just bought this dvd 1 week ago and...
Excellent read, I just passed this on...
Really meaningful picture
whats wrong with taxonomy, yes Joomla...
I love drupal in-fact I have now desi...
great work, how much you charge per p...
I agree that "the profiles are of...