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.
I installed today's version of 4.7 cck. (also on earlier versions)
I thought a field title would not show up if a field is blank.
on a post, field titles are showing even when the field is blank.
This does not look pretty and I think will be quite confusing for the person surfing.
Comment | File | Size | Author |
---|---|---|---|
#2 | content.module.hide-empty-fields.diff.txt | 1.24 KB | jpetso |
Comments
Comment #1
KarenS CreditAttribution: KarenS commentedThis is a theme issue. Read about themeing in the CCK Handbook at http://drupal.org/node/101723.
Comment #2
jpetso CreditAttribution: jpetso commentedWhile it is possible to do this with theming, I feel that this is far more complex and demanding than it should be. The comments at http://drupal.org/node/62485 show that it's not straightforward and especially not for non-coders. I believe that empty fields should be hidden by default, and if it's not hardcoded it should at least be a simple checkbox in the field properties. Oh, and, Flexinode hides them as well.
I hacked a small patch together (for the 4.7 version of CCK's content.module) which hides all empty fields by theming them out in theme_field(). I'm new to Drupal coding, so slap me if I've done it wrong. Or maybe include it into CVS, whatever ;)
Anyhow, please state some use cases where not hiding empty fields would be needed, and the reasons why you think they should be visible by default.
Comment #3
jpetso CreditAttribution: jpetso commented...and reopen the bug with the patch being in here. I'm sorry to go on your nerves this way, but marking it "fixed" this way is just too easy.
Comment #4
yched CreditAttribution: yched commentedActually I think we should consider doing this - Would save time to most users and save us much support requests...
Karen, dopry, what do you think ?
Comment #5
KarenS CreditAttribution: KarenS commentedSure, I have no objection. I guess I was just trying to clean things out of the issue queue that can be done already. Maybe I was too quick to check this one off :-)
As I think about it, I suppose the normal use case would be to not display the label and use themeing if you wanted a different outcome. I've got no time to do this myself right now, but go ahead yched when you have time.
Comment #6
yched CreditAttribution: yched commentedYes, will do that :-)
Comment #7
yched CreditAttribution: yched commentedcommitted a simpler version to all branches
Comment #8
jpetso CreditAttribution: jpetso commentedThanks a lot!
Just two minor issues with your modifications:
- The last
appended to $output isn't closed:
$output .= '</div';
should be
$output .= '</div>';
-
if (!empty($items_output))
returns the $output string, but there's no return statement in case the condition is false.It would probably be better if there was an
else { return ''; }
.I reopened the bug for these issues to be fixed.
Comment #9
yched CreditAttribution: yched commentedcorrected - thanks !
Comment #10
(not verified) CreditAttribution: commentedComment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedHi all,
When I install a CCK formatter like cck multiple formatter or cck formatter, blank fields printing their field headers. Specifically, the fields that are printing are those in which I assigned to display as an unordered list (as assigned in the display fields tab).
Can anyone direct me how I might solve this problem?
Tanks!