In D6 there was a custom block.tpl.php, which gave the sidebar block titles a unique look.

I have completed a basic port of this to D7. I did this in the following 3 steps.

1. Copy block.tpl.php exactly over from D6.
NOTE: This throws an error regarding a missing function "wordlimit".

2. Copy the wordlimit into template.php. It works identically to D6 except I clarified in the comment that it is for block titles.

/**
 * Function spanify firstword of block titles
 */
function wordlimit($string, $length = 50, $ellipsis = "...") {
  $words = explode(' ', strip_tags($string));
  if (count($words) > $length)
    return implode(' ', array_slice($words, 0, $length)) . $ellipsis;
  else
    return $string;
}

NOTE: This doesn't throw errors but doesn't print the content of the block.

3. Finally I pulled up the default block template file from modules/block/block.tpl.php and copied the appropriate parts.
https://api.drupal.org/api/drupal/modules%21block%21block.tpl.php/7
Here is my entire block.tpl.php minus the comment section.

<?php
// $Id: block.tpl.php,v 1.1 2010/08/05 07:51:20 antsin Exp $
?>

<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>" <?php print $attributes; ?>>
  <?php print render($title_prefix); ?>
  <?php if (($block->subject) && (($block->region !='header')&&($block->region !='left')&&($block->region !='footer_one')&&($block->region !='footer_two')&&($block->region !='footer_three')&&($block->region !='footer_four'))): ?>
      <?php $firstword = wordlimit($block->subject, 1, "");
      $block->subject = str_replace($firstword, "<span class=\"first-word\">" . $firstword . "</span>", $block->subject); ?>
  <h2 class="title" <?php print $title_attributes; ?>><?php print $block->subject; ?></h2>
	  <div class="makeup"></div>
    <?php elseif ($block->subject): ?>
      <h2 class="title" <?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>
</div>

Comments

benlotter’s picture

Issue summary: View changes

Removed references to block_class since it was throwing an error and I don't what functionality it provides.

benlotter’s picture

There are serious performance implications to this block.tpl.php which I haven't figured out yet. For example, it makes

content from 3rd part take forever to render such as Disqus comments and Amazon store items. I'll keep working on the solution.