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.
-
2please read [What have you tried](http://www.whathaveyoutried.com) and [FAQs](http://www.stackoverflow.com/faq) – UnholyRanger Mar 07 '13 at 15:29
4 Answers
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.

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

- 1,392
- 15
- 33
-
Thank you Merijn! It works fine but I don't know why it doesn't work only for the Search form block!? Any idea how I can solve this? – user2144918 Mar 08 '13 at 09:41
-
The problem is solved. I have removed the h2 tag from the search module. – user2144918 Mar 08 '13 at 11:18
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.

- 4,618
- 2
- 29
- 48
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".

- 111
- 3