Skip to main content
3 of 5
added 773 characters in body
Jack-PL
  • 2.6k
  • 2
  • 22
  • 27

Yes, you can do that with preprocess_block() function.

just define title prefix and suffix.

For example:

/**
 * Override or insert variables into the block template.
 */
function YOURTHEME_preprocess_block(&$variables) {

 // block with title "My music" will be wrapped in music icon 
 if ($variables['block']->title == 'My music') {
    $variables['title_prefix'] = '<i class="icon-music">';
    $variables['title_suffix'] = '</i>';
 }
}

Your default block.tpl.php already render the prefix and suffix:

<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
    <?php print render($title_prefix); ?>
        <?php if ($block->subject): ?>
            <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
        <?php endif;?>
    <?php print render($title_suffix); ?>
    <div class="content"<?php print $content_attributes; ?>>
        <?php print $content ?>
    </div>
</div> 
Jack-PL
  • 2.6k
  • 2
  • 22
  • 27