So I see this in the block.tpl.php:

* @file
* Default theme implementation to display a block.
* Available variables:
* - $block->subject: Block title.
* - $content: Block content.
* - $block->module: Module that generated the block.
* - $block->delta: An ID for the block, unique within each module.
* - $block->region: The block region embedding the current block.
* - $classes: String of classes that can be used to style contextually through
*   CSS. It can be manipulated through the variable $classes_array from
*   preprocess functions. The default values can be one or more of the
*   following:
*   - block: The current template type, i.e., "theming hook".
*   - block-[module]: The module generating the block. For example, the user
*     module is responsible for handling the default user navigation block. In
*     that case the class would be 'block-user'.
* - $title_prefix (array): An array containing additional output populated by
*   modules, intended to be displayed in front of the main title tag that
*   appears in the template.
* - $title_suffix (array): An array containing additional output populated by
*   modules, intended to be displayed after the main title tag that appears in
*   the template.

I'm trying to set the $title_prefix & $title_suffix in my hook_block_view without much luck...

Here is the working version of what I have:

* Implements hook_block_view().
function activities_block_view($delta = '') {
 switch ($delta) {
   case 'find_activities_small':
     $block['subject'] = t('Find Activities');
     $block['content'] = drupal_get_form('find_activities_form');
     return $block;

3 Answers 3


Core (modules/block/block.tpl.php) and other themes I checked output the title_prefix with:

<?php print render($title_prefix); ?>

Therefore, the format of $title_prefix is any renderable array. You can override theme_preprocess_block() function in template.php to supply values. For example,

function mytheme_preprocess_block(&$variables) {
  $variables['title_prefix'] = array(
    '#type' => 'markup',
    '#markup' => '<span>My title prefix</span>',
  1. You can hard code in block template: "Drupal 7 Template Suggestions", so determine what module/delta/region appropriate for you.
  2. Other way is using theme preprocessor.

Why insert more html when you can simply use css with a class insert through the Block Class module? Here is an excerpt about it from the module's project page:

... allows users to add classes to any block through the block's configuration interface. By adding a very short snippet of PHP to a theme's block.tpl.php file, classes can be added to the parent <div class="block ..."> element of a block. Hooray for more powerful block theming!

  • Adding wrapper is different from adding a class... and even adding class with block_class will add a class to the block itself not to the block-title
    – jramby
    Feb 27, 2013 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.