I always like to have empty CCK fields completely disappear from the node-viewing page - it's all nice to have a bunch of fields for all possible things, but never show a lame page with most fields blank. I even creatd a patch previously to do this.
As of upgrading to 5.x-1.5 now, I see that this is already implemented - that's great. But there's a problem: The check for the field being empty is done AFTER all the input-format filters, so the empty fields are (in my config) never detected as being empty, because of all kinds of empty DIV's, BR's with float-clearing classes, HTML comments with filter version etc. etc. Simply the filters sometimes add invissible markup-mess even to empty fields.
So, I think that the check for empty fields should be done BEFORE filtering (alternatively not calling the filter at all, if empty).
I have a sort of patch working, but it's senseless here, as it's just a workaround with hacked filtering-module.
It would be also nice, to have this behaviour (hiding empty fields) configurable, to avoid confusion of other users, who don't want it.
Comments
Comment #1
yched commentedI'm tempted to mark as 'by design', for I don't think this can work that way.
Before we can decide if there is something to display or not, we do have to let the formatters get a chance to run;
Some formatters for some field types might decide to display something for 'empty' values.
Some formatters (is it imagefield ?) even leave the actual output to theme functions, meaning the theme / themer might override the default behaviour and treat empty values the way they like.
Besides, there is not really any generic concept of 'empty' value, this might depend on the field type : NULL, empty string, 0... ?
The only reliable criteria we have is 'is the output string empty' ?
I think the best approach is to try and see why you filters return 'almost but not empty' strings ?
About the setting to turn 'hiding empty fields' on / off - i remember we thought about it when the field display part was reworked a few months ago, and decided it would mainly add confusion to the cck settings pages, that are crowded enough already. This might be reconsidered of course, but in about 6 months time, you're the only one who actually pointed that :-)
For the time being, this behaviour is coded in a theme function, so it can easily be overrided.
Comment #2
JirkaRybka commentedOkay, I'll stick with my custom patching on each upgrade, then. No big deal about that, I just thought it might be good to solve in a more clean way, if possible. I meant textfields (the only ones for text-input filters, in my case at least), where the "empty string" condition is no problem.
BTW, the filtering module I speak of is Texy!, the pseudo-markup formatter. Any empty field after applying Texy looks like this:
<p></p><br class="clear" /><!-- By Texy! 2 -->And I can't do anything about it cleanly. (I have a patch to detect empty fields myself, and avoid the main filtering function at all, but that's just a quick hack.)Comment #3
yched commentedSounds like a (non-minor) bug in Texy ...
But, well, maybe you're right, the specific formatter for text fields could check if the value is empty - could possibly even trim the thing first...
Setting back to active :-)
Comment #4
catchhttp://drupal.org/node/129908 was duplicate. There's a few issues related to this this I think.
http://drupal.org/node/101050 is related but since it's views specific I'll leave both open.
Comment #5
catchhttp://drupal.org/node/57228 is pretty much a duplicate as well.
Comment #6
deekayen commented@JirkaRybka: I'm going to have to do something about this issue on one of my projects. If you could dig up that old patch and post it here, there are duplicate issues pointing here where I'm sure people would find it interesting.
Comment #7
cornmuffin commentedI had fieldgroups which each display nodereferrers of a specific content type. Since these fieldgroups only contain nodereferrer fields they should not be displayed in the node edit form.
Comment #8
JirkaRybka commentedMy old patch (still running on the live site) was against the Texy! module, to detect empty input and avoid the call to the formatter itself in that case, preserving the emptiness... Nothing closely bound to CCK, so I don't think it belongs here. ;)
Comment #9
deekayen commentedChange the status on this issue based on http://drupal.org/node/277101 ?
Comment #10
JirkaRybka commentedI have no problems with this anymore, so I assume it's fixed now.
(Cleaning outdated issues in my personal queue... Feel free to re-open if needed!)
Comment #12
intuited commentedIf a field group just contains computed fields, the group is displayed but is empty. This seems to me a bug, though maybe one with computed field rather than with the field group.
Comment #13
intuited commentedI'm feeling like it was a mistake to file this here, since it does seem to be a problem with computed field and not CCK fieldgroups.
I've filed a bug on that project: #616542: fieldgroups which only contain computed fields are displayed (and empty) in node edit forms.
Comment #14
markus_petrux commentedThis is not related to CCK. Please, also see #349548: Conditional result for hook_content_is_empty()