Adding classes to block title I have a block which template I'm overriding with my own. 

The title in it is displayed by the following code:

    &lt;h2&lt;?php print $title_attributes;?&gt;&gt;&lt;?php print $title; ?&gt;&lt;/h2&gt;


I just want to add some custom classes to the h2, but I can't figure out how to format it. I want to keep $title_attributes but I can't seem to be able to add my own classes if I do.

I tried:

    &lt;h2 class="a-class" &lt;?php print $title_attributes;?&gt;&gt;&lt;?php print $title; ?&gt;&lt;/h2&gt;


and:

    &lt;h2&lt;?php print $title_attributes .'a-class';?&gt;&gt;&lt;?php print $title; ?&gt;&lt;/h2&gt;


But neither did anything. My PHP is scrappy at best so it's probably just me who don't know how to write what I want. Can anyone help me?
The way to do this is by overriding variables in the template. Put the following code in your themes 'template.php' file, replacing YOURTHEME, YOURBLOCK, YOURCLASS with the obvious.

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

  // var_dump($vars);

  $block = $vars['block'];

  if ($block-&gt;delta == 'YOURBLOCK') {
    $vars['title_attributes_array']['class'][] = 'YOURCLASS';
  }

}


You can determine what the $block->delta is for example by doing a var_dump($vars) in the function. If you have the DEVEL module installed you can use dsm($vars) which gives the dump some presentation.