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

Bence - January 17, 2008 - 17:30

Oops :) So the code look like this:

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

#2

jwolf - January 18, 2008 - 08:42
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

prfctgdess - February 4, 2008 - 16:17

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

jwolf - February 5, 2008 - 01:34

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

#5

jefftrnr - May 27, 2008 - 22:44

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

 
 

Drupal is a registered trademark of Dries Buytaert.