Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#21 | theme.inc.theme_block_1.patch | 994 bytes | the greenman |
#18 | theme.inc.theme_block_0.patch | 994 bytes | the greenman |
#16 | theme.inc.theme_block.patch | 1018 bytes | the greenman |
#14 | theme.inc_1.315_p01.txt | 1.97 KB | AjK |
#13 | theme-inc-cleanup_0.diff | 2.06 KB | nickl |
Comments
Comment #1
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedneeds a review.
Comment #2
rkerr CreditAttribution: rkerr commented+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.
Comment #3
Morbus IffUpdated per berkes' comment on endif usage in pushbutton and defaults.
Comment #4
Morbus IffGah. Too many spaces.
Comment #5
Bèr Kessels CreditAttribution: Bèr Kessels commentedLooks 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
Comment #6
Morbus IffComment #7
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedapplied
Comment #8
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedThe 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:
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..
Comment #9
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedMaybe 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... ;-)
Comment #10
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedNot 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?
Comment #11
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedKilles, 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..
Comment #12
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedKilles, what do you think about this? Should I update the patch?
Comment #13
nickl CreditAttribution: nickl commentedRerolled to fresh head
Comment #14
AjK CreditAttribution: AjK commentedThis commit broke nickl's patch in #13
http://drupal.org/cvs?commit=39798
Re-rerolled.
regards,
--AjK
Comment #15
beginner CreditAttribution: beginner commentedThe 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().Comment #16
the greenman CreditAttribution: the greenman commentedHere 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.
Comment #17
beginner CreditAttribution: beginner commentedThe patch does not apply because of non-standard line endings.
Please see:
http://drupal.org/patch#endings
Comment #18
the greenman CreditAttribution: the greenman commentedPatch converted to Linux line endings.
Comment #19
rkerr CreditAttribution: rkerr commentedThe 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).
Comment #20
RobRoy CreditAttribution: RobRoy commentedWhat about if $block->subject == '0'? In your patch that title wouldn't be printed. Consider using isset() and/or !== '' if it is always set.
Comment #21
the greenman CreditAttribution: the greenman commentedAhh, 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.
Comment #22
Dries CreditAttribution: Dries commentedAnd what if a block has no content? Can it happen?
Comment #23
beginner CreditAttribution: beginner commentedI 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().
Comment #24
ricabrantes CreditAttribution: ricabrantes commentedAny news about this bug??
Comment #25
neclimdulThe second part of this could break expected functionality at this point and doesn't apply to d6 and beyond.