Comments

dawehner’s picture

Status: Active » Fixed

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

rbrownell’s picture

Status: Fixed » Active

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

rbrownell’s picture

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

chx’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Active » Needs review
StatusFileSize
new2.16 KB

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

kafka93’s picture

Status: Needs review » Reviewed & tested by the community

I'm with chx -- the patch provided in #4 makes this work as one would expect.

dawehner’s picture

Status: Reviewed & tested by the community » Needs work

Sadly this patch doesn't apply anymore.

I'm wondering whether using constant for the phases would improve the readability of the code.

Mixologic’s picture

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

derhasi’s picture

Status: Needs work » Needs review
StatusFileSize
new3.3 KB

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

kevin.mcnamee@mailbox.org’s picture

Subscribing. Will the problem be fixed in 6.3 too?

/Kevin

kevin.mcnamee@mailbox.org’s picture

Rerolled patch hide_alter_empty_should_not_hide_the_no_results_text-1273486-8.patch for 6.x-3.x. Seems to work fine.

/Kevin

atolson’s picture

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

imclean’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Patch (to be ported) » Needs review
StatusFileSize
new3.17 KB

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

intrafusion’s picture

I can confirm patch #12 works fine for me with my issue #1421456: Comment count: Rewrite results doesn't work with No results behavior

dawehner’s picture

StatusFileSize
new5.87 KB

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

dawehner’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Needs review » Patch (to be ported)

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

calefilm’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Needs review » Patch (to be ported)

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

atolson’s picture

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

calefilm’s picture

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

atolson’s picture

@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

+    // Only in empty phase.
+    if ($alter['phase'] == VIEWS_HANDLER_RENDER_TEXT_PHASE_EMPTY && $no_rewrite_for_empty) {
+      // If we got here then $alter contains the value of "No results text"
+      // and so there is nothing left to do.
+      return $value;
+    }
+
     if (!empty($alter['strip_tags'])) {
       $value = strip_tags($value, $alter['preserve_tags']);
     }

6.x.2.16

    if (!empty($alter['strip_tags'])) {
      $value = strip_tags($value);
    }
calefilm’s picture

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

atolson’s picture

@calefilm - OK. Thanks for the reply. I suppose I'll hold out for a 6.x.2.x branch patch.

kevin.mcnamee@mailbox.org’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new8.44 KB

Rerolled the patch in #10 and applied the unit tests patch in #14.

/Kevin

Status: Needs review » Needs work
chingis’s picture

StatusFileSize
new757 bytes

Attached 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

djdevin’s picture

#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

imclean’s picture

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

fgm’s picture

hvalentim’s picture

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

mustanggb’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)