Download & Extend

H2 block titles should disappear if no title specified

Project:Celju
Version:5.x-1.1
Component:Code
Category:task
Priority:minor
Assigned:jwolf
Status:active

Issue Summary

If I don't specify title for a block, then the code looks like this:

[...]

[...]

But h2.title has 1px solid border, so a narrow empty box will appear above a block which has no title.

Comments

#1

Oops :) So the code look like this:

[...]
<div class="block block-block" id="block-block-6">
    <h2 class="title">
          </h2>
[...]

#2

Category:bug report» task
Priority:normal» minor
Assigned to:Anonymous» jwolf

Solution is to edit block.tpl.php as follows:

  <div class="block block-<?php print $block->module; ?>" id="block-<?php print $block->module; ?>-<?php print $block->delta; ?>">
 
    <?php if($block->subject) : ?>
    <h2 class="title">
      <?php print $block->subject; ?>
    </h2>
    <?php endif; ?>
    <div class="content">
      <?php print $block->content; ?>
    </div>
  </div>

Note the:

    <?php if($block->subject) : ?>
    <h2 class="title">
      <?php print $block->subject; ?>
    </h2>
    <?php endif; ?>

#3

OK, this may sound dumb, but I'm a Drupal newbie, so please bear with me. :P

I'm having this problem too, and I understand your solution, but where do I find block.tpl.php? I can't seem to find it! Thanks.

#4

block.tpl.php is located in the theme's directory; it came with the theme.

#5

I believe another solution is to put the string <none> within the block title field, if you don't want to show the title.

#6

Putting < does not work for me..

#7

The Solution provided by Jwolf worked perfectly.
Thanks

nobody click here