Closed (won't fix)
Project:
Views (for Drupal 7)
Version:
6.x-3.x-dev
Component:
fieldapi data
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Sep 2011 at 19:06 UTC
Updated:
25 Aug 2017 at 11:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dawehnerThis seems to be a bit unlogical, because you either want to hide it, or you want to change the text with an empty text.
So what you probably want to have the checkbox unchecked.
Comment #2
rbrownellHow does it seem illogical? Perhaps I shouldn’t have used the word ‘hide’.
How about this rewording of it: Right now if a field is empty and being rewritten with the “Hide rewriting if field is empty” option selected it hides the entire thing. What I would like to do is replace the rewritten field with the Empty Text. Before the "Hide rewriting if field is empty" was available we couldn’t hide an empty field that was rewritten. What I am trying to achieve is treat a rewritten field as empty if the field is empty.
Should function more like "Treat rewriting as empty if field is empty"
What I am trying to do is simple: If the field is empty, don't just hide the rewrite, treat it like it is empty, so we can use Empty Text.
Does this make more logical sense?
Comment #3
rbrownellThe inability to treat rewriting in fields that are empty as empty is particularly an issue if you include another field in the rewrite. The ability to do that would create the ultimate if else functionality in views. Almost like how one can create nested if's in Excel.
Comment #4
chx commentedIn my opinion, clicking " Hide rewriting if empty" should hide the contents of "Rewrite results" but not "No results text". Otherwise, token support in "No results text" is a bit pointless, isn't it?
Patch sponsored by ITV.
Comment #5
kafka93 commentedI'm with chx -- the patch provided in #4 makes this work as one would expect.
Comment #6
dawehnerSadly this patch doesn't apply anymore.
I'm wondering whether using constant for the phases would improve the readability of the code.
Comment #7
MixologicGolly. I sure wish I hadnt spent about 6 hours trying to figure out why my blocks disappeared on my site after upgrading views. Turns out this checkbox was set to checked by default, which caused my "no results text tokens" to be suppressed.
+1 for chx's patch in #4 - does it need a re-roll?
Comment #8
derhasi commentedchx, dereine, I re-rolled the patch (to current 3.1), added/changed some comments and added constants for the phases.
If you need a -dev version, please let me know.
Comment #9
kevin.mcnamee@mailbox.org commentedSubscribing. Will the problem be fixed in 6.3 too?
/Kevin
Comment #10
kevin.mcnamee@mailbox.org commentedRerolled patch hide_alter_empty_should_not_hide_the_no_results_text-1273486-8.patch for 6.x-3.x. Seems to work fine.
/Kevin
Comment #11
atolson commentedI appear to have this problem in 6.x-2.16.
What I want to happen is "Treat rewriting as empty if field is empty."
I have recently noticed that this is no longer working on my site. After reading the multiple issue queues on empty text, hidden field, rewrite field, it seems most likely that my problems began after upgrading to 2.16 (from 2.12 I believe).
Is there any hope for a patch for Views 2?
Comment #12
imclean commented@derhasi, #8 applies to dev ok. This one's the same only created from the module's root directory.
There seem to be a few related problems with "hide rewriting if empty":
#1330148: Empty text not working when rewrite output is selected
#1433596: "Hide rewriting if empty" always thinks zero is empty
#1428256: No results behavior "Hide rewriting if empty " is not working
Edit comment: addressed wrong post.
Comment #13
intrafusionI can confirm patch #12 works fine for me with my issue #1421456: Comment count: Rewrite results doesn't work with No results behavior
Comment #14
dawehnerI created some tests for this problem, as it is quite hard to actually test everything manually.
Without this bug the tests fails on three places, though with the patch it works as expected, yeah! Thanks!
I "fear" that this bugs exists on all three versions, so it has to be applied for 6.x-2.x as well, does someone disagree with that?
We try to minimize the work on 6.x-2.x, because "stable" is meant literally here .
Comment #15
dawehnerReviewed the patch a final time, that's perfect. Committed the patch to 7.x-3.x.
Thanks for everyone, who has worked on this issue.
Mark:
* This patch should be applied to 6.x-2.x, 6.x-3.x
* The test has to be applied to 6.x-3.x as well.
Comment #16
calefilm commentedJust like atolson above I'm having trouble with this issue on 6.x-2.16. I tried applying the patches but they don't succeed. Am I just not applying them right? The patch applies fine in 6.x-3.x-dev but I'm not succeeding in patching 2.16. Or is there somewhere else I can go to grab a patch for 2.16?
Comment #17
atolson commentedI tried applying the patch in #10 manually to 6.x-2.16.
The symptoms have changed but I still don't get what I used to get before the views upgrade.
Before the patch:
Rewrite output = [some_field]
Empty text = some empty text
When some_field = empty, result in view is empty.
After the patch:
Rewrite output = [some_field]
Empty text = some empty text
When some_field = empty, result in view is rewritten output ([some_field])
Thinking that the "Count the number 0 as empty", "Hide if empty", or "Do not rewrite if empty" options might not be set correctly, I played around with combinations (all?), but this didn't affect the result.
Is this because the 6.x.2.16 needs to be patched differently than 6.x.3.x or is there something else going on here?
Comment #18
calefilm commentedI gave up and reverted back to 6.x-2.15 which works great. It is the last version before the big upgrade--frankly, i like the user interface better.. less is easier to work with. So that's a thought. Sorry, I can't help but until upgrading views is necessary i'll hold out with this version for as long as i can.
Comment #19
atolson commented@calefilm - To revert back was it just a matter of reverting back to the 6.x.2.15 source code or were there database changes as well.
I wish I could be more helpful in getting a 6.x.2.16 patch in place. Feels backward to have the non-recommended version (6.x.3.0) fixed before the recommended version (6.x.2.16).
When I say that I applied the #10 patch manually, I mean that for each section of new code in the patch I did a Ctrl+F find (in 6.x.2.16) for a line of code adjacent to the section of code in the patch and then added/subtracted as described. For what it's worth other than the location of the code, I found very little difference in the code directly adjacent to the added or subtracted code in the patch files. The only difference I found was in the last section:
Patch #10
6.x.2.16
Comment #20
calefilm commentedSorry, i can't answer your question in depth as I'm not as experienced. I have found that my site breaks (i get random errors) anytime I revert back a level on a module. In my case, I created a new database, and before I restored the old db, I replaced the 6.16 views module with 6.15 and upon migrating the site works as it should. So I suppose my answer would be that there were 'database changes' as I had to go back a few days to a previous drupal version.
Comment #21
atolson commented@calefilm - OK. Thanks for the reply. I suppose I'll hold out for a 6.x.2.x branch patch.
Comment #22
kevin.mcnamee@mailbox.org commentedRerolled the patch in #10 and applied the unit tests patch in #14.
/Kevin
Comment #24
chingis commentedAttached simple patch to fix it quickly, checked on 6.x-3.0
the point of this patch - check for original value for 0 after it was overridden by rewrite text
so if it's equal to 0, then we check for empty text and if it was specified - display it
Comment #25
djdevin#24 worked for us. For example we have a field "Status" that is 0 or 1
When 1 it should display Yes (rewrite output)
When 0 should display No (empty text)
Hide rewriting is unchecked
Count 0 as empty is checked
Comment #26
imclean commented@csandanov, see also #1433596: "Hide rewriting if empty" always thinks zero is empty. I think the patch in #21 covers this for 7, still needs to be ported to 6.
Comment #27
fgmThe latest committed version causes this other issue #1548240: this->original_value does not always exist in views_handler_field->render_text() (line 1118.
Comment #28
hvalentim commentedJust upgraded to 6.x-2.16 from 6.x-2.13 and discovered this issue (unable to show a given "empty text" when field is empty while using the "Rewrite the output of this field" and "Do not rewrite if empty" options).
One can hide a rewritten empty field altogether, but not replace it some text (e.g. "info not available for this particular entry").
Anyone found a solution for this?
Comment #29
mustanggb commented