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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

KarenS’s picture

Status: Active » Fixed

This is a theme issue. Read about themeing in the CCK Handbook at http://drupal.org/node/101723.

jpetso’s picture

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

jpetso’s picture

Status: Fixed » Needs review

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

yched’s picture

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

KarenS’s picture

Sure, 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.

yched’s picture

Assigned: Unassigned » yched

Yes, will do that :-)

yched’s picture

Status: Needs review » Fixed

committed a simpler version to all branches

jpetso’s picture

Status: Fixed » Active

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

yched’s picture

Status: Active » Fixed

corrected - thanks !

Anonymous’s picture

Status: Fixed » Closed (fixed)
Anonymous’s picture

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