- Install this module from the url : https://www.drupal.org/project/block_class
- Enable this module
- Go into page 'admin/structure/block' and click 'configure' of which block you want to add classes to
- The configuration page for the block shows up and set up the classes in the input of 'CSS classes'.
- Create a block template file for this specific view referring to drupal template suggestions. For example: block--views--whats-new-whats-new-block.tpl is for the block with the machine name 'whats-new' which can be easily found by 'theme developer'
- Copy the code of block.tpl.php into the specific block template file which created at step 5
<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>> <?php print render($title_prefix); ?> <?php if ($title): ?> <h2<?php print $title_attributes; ?>><?php print $title; ?></h2> <?php endif; ?> <?php print render($title_suffix); ?> <?php print $content; ?> </div><!-- /.block --> - Tweak the first line of the step 6 code by adding 'print $block_classes' snippet
<div id="<?php print $block_html_id; ?>" class="<?php print $classes . ' ' . $block_classes; ?>"<?php print $attributes; ?>> <?php print render($title_prefix); ?> <?php if ($title): ?> <h2<?php print $title_attributes; ?>><?php print $title; ?></h2> <?php endif; ?> <?php print render($title_suffix); ?> <?php print $content; ?> </div><!-- /.block -->
Monday, 9 March 2015
Block Class
Labels:
Modules
Subscribe to:
Post Comments (Atom)


No comments:
Post a Comment