Download & Extend

cck field titles are showing even when field is blank

Project:Content Construction Kit (CCK)
Version:4.7.x-1.x-dev
Component:General
Category:feature request
Priority:normal
Assigned:yched
Status:closed (fixed)

Issue Summary

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.

Comments

#1

Status:active» fixed

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

#2

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.

AttachmentSize
content.module.hide-empty-fields.diff.txt 1.24 KB

#3

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.

#4

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 ?

#5

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.

#6

Assigned to:Anonymous» yched

Yes, will do that :-)

#7

Status:needs review» fixed

committed a simpler version to all branches

#8

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.

#9

Status:active» fixed

corrected - thanks !

#10

Status:fixed» closed (fixed)

#11

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!