How to remove H2 tag from some blocks

2.8k views Asked by At

I would like to remove the H2 tag from search and some other blocks (not from all of them by block.tpl.php). I use sub theme of Zen. Hope somebody can help me.

4

There are 4 answers

2
Hacktisch On BEST ANSWER

Go to blocks configuration page -> edit block -> enter <none> as a title.
This is the CMS way and this is how you should do it.

0
AKS On

Clive has already answered the question which is, IMO, correct - but as you are saying you are not very experienced with PHP, let me suggest something that does not involve coding - but keep in mind: Learning Drupal and PHP is easy and a fun if you have plenty of time to read docs and testing.

From "remove h2", I'm assuming you mean to remove the h2 tag with class title. In the block's configuration page, enter <none> as the title of the block - your block will not contain the title (and its h2 tag).

This is a per-block setting.

0
in Cina On

Assuming that you want to remove the H2 tag for SEO reasons, I'd like to suggest a trick to take advantage of the "Search form" string.Find for "Search form" Label from your language file (default english)and replace it with "Your SEO Text".

2
Clive On

It's a vague question so the answer will be equally vague...

function MYTHEME_preprocess_block(&$vars) {
  if ($vars['block']->info == 'foo') {
    $vars['theme_hook_suggestions'][] = 'block__no_title';
  }
}

Then add a block--no-title.tpl.php file to your theme, copy the markup from block.tpl.php, and remove the <h2>. Clear Drupal's theme registry cache and you're done.