Bluemarine, pushbutton, and phptemplate all ship a box.tpl.php file which simply prints out a title and the actual content. Occasionally, however, a title doesn't actually exist for a box (such as the comment_form on a preview). This causes an empty [h2] to spit out and, in certain CSS formattings (such as a background color and margins/paddings), can cause a visual irregularity. The attached patch simply spits out the [h2] only if the title exists. Nothing big.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

killes@www.drop.org’s picture

Status: Reviewed & tested by the community » Needs review

needs a review.

rkerr’s picture

+1

Patch applies and works as advertised. This is something I do in all my themes anyway, so it makes sense to me that the default themes also behave nicely.

Morbus Iff’s picture

FileSize
1.76 KB

Updated per berkes' comment on endif usage in pushbutton and defaults.

Morbus Iff’s picture

FileSize
1.71 KB

Gah. Too many spaces.

Bèr Kessels’s picture

Looks lovely. And works as advertised. Its something I do in all my themes too, so its gets a warm +1 from me :)

LESS HTML = LESS clutter == good

Morbus Iff’s picture

Status: Needs review » Reviewed & tested by the community
killes@www.drop.org’s picture

Status: Reviewed & tested by the community » Fixed

applied

Stefan Nagtegaal’s picture

Status: Fixed » Needs work

The Chameleon-theme and all other PHP-based themes don't rely on PHPTemplate, so theme.inc should be updated as well..

Unfortunatly I'm not in the position to make a proper patch ATM, but replacing theme_box (line 799 of theme.inc) with:

function theme_block($block) {
  $output  = "<div class=\"block block-$block->module\" id=\"block-$block->module-$block->delta\">\n";
  if ($block->subject) {
    $output .= " <h2 class=\"title\">$block->subject</h2>\n";
  }
  $output .= " <div class=\"content\">$block->content</div>\n";
  $output .= "</div>\n";
  return $output;
}

This does the job.. Could someone please roll this into a patch and directly set this RTBC? I did test this on all my 6 custom themes and Chameleon and it works..

Stefan Nagtegaal’s picture

Status: Needs work » Needs review
FileSize
1.94 KB

Maybe it's a little late, but hey... Here it is!

This also cleans up theme_page() a little which was pretty outdated..

I would say, RTBC bt killes would kill me for that... ;-)

killes@www.drop.org’s picture

Not sure we should apply this one. This will change the default for all themes (inclusive custom ones). I am reluctant to do that this late in the release cycle. Can't we make chameleon implement implement theme_block?

Stefan Nagtegaal’s picture

Killes, I am not adding a new feature here.
I am only taking away the difference between the way PHPTemplate handles this and the Plain PHP themes. For sake of consistency that is.. IMO we could consider this as a bug, because we have different functionality in PHPTemplate and Plain PHP themes..

Stefan Nagtegaal’s picture

Killes, what do you think about this? Should I update the patch?

nickl’s picture

FileSize
2.06 KB

Rerolled to fresh head

AjK’s picture

FileSize
1.97 KB

This commit broke nickl's patch in #13

http://drupal.org/cvs?commit=39798

Re-rerolled.

regards,
--AjK

beginner’s picture

Status: Needs review » Needs work

The patch includes more than there needs to be. The first two hunks can be moved to another issue (esp. I am not sure the "begin content" and "end content" ought to be removed).

Only the third hunk is relevant here.

if ($block->subject) will create an E_ALL notice. Use !empty().

the greenman’s picture

Version: x.y.z » 5.x-dev
Status: Needs work » Needs review
FileSize
1018 bytes

Here is a simplified patch. We removed all the extra stuff and just created a patch for theme_block. We also use !empty to make things safer.

beginner’s picture

Status: Needs review » Needs work

The patch does not apply because of non-standard line endings.
Please see:
http://drupal.org/patch#endings

the greenman’s picture

FileSize
994 bytes

Patch converted to Linux line endings.

rkerr’s picture

Status: Needs work » Needs review

The latest patch applies. Looks reasonable to me.
Is there a conscious effort in D5 to remove linebreaks from generated HTML?
(Just wondering, I don't think it should affect the patch's acceptance).

RobRoy’s picture

Status: Needs review » Needs work

What about if $block->subject == '0'? In your patch that title wouldn't be printed. Consider using isset() and/or !== '' if it is always set.

the greenman’s picture

Status: Needs work » Needs review
FileSize
994 bytes

Ahh, you learn something new every day, I had actually assumed that empty worked just the same as isset. Now using isset.

This patch is also removing all the extra newlines that were in the original output, I can't see it adding any.

Dries’s picture

And what if a block has no content? Can it happen?

beginner’s picture

Status: Needs review » Needs work

I tested with chameleon, a theme that does not use phptemplate.

@dries#22: a block without body in not printed at all (I tried). No problem here.

The check should be isset() rather than !isset().

ricabrantes’s picture

Any news about this bug??

neclimdul’s picture

Status: Needs work » Closed (fixed)

The second part of this could break expected functionality at this point and doesn't apply to d6 and beyond.