H2 block titles should disappear if no title specified
Bence - January 17, 2008 - 17:28
| Project: | Celju |
| Version: | 5.x-1.1 |
| Component: | Code |
| Category: | task |
| Priority: | minor |
| Assigned: | jwolf |
| Status: | active |
Jump to:
Description
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.

#1
Oops :) So the code look like this:
[...]<div class="block block-block" id="block-block-6">
<h2 class="title">
</h2>
[...]
#2
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.