1

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.

apaderno
  • 28,547
  • 16
  • 75
  • 90
user2144918
  • 23
  • 1
  • 5

4 Answers4

2

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.

Clive
  • 36,918
  • 8
  • 87
  • 113
  • Ok. I have created the file block--no-title.tpl.php without

    but I don't know where to place the code - I have tried in template.php of my sub theme (also in the Zen theme) but there is the error "Notice: Undefined property: stdClass::$info in MYTHEME_preprocess_block()" with the name of my theme. Can you please enplane in details what I have to do because I am not so experienced in Drupal and php.

    – user2144918 Mar 07 '13 at 16:36
  • Sorry no, if you don't know PHP or Drupal I can't help you – Clive Mar 07 '13 at 16:41
2

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.

Hacktisch
  • 1,392
  • 15
  • 33
1

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.

AKS
  • 4,618
  • 2
  • 29
  • 48
1

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".

in Cina
  • 111
  • 3