I noticed this while testing #510910: When multiple fields share a column in table view only the last field displays. If you define a "Global: Custom text" field and give it the value "0", that won't show up in your view, apparently due to some render() related special case for rewriting and custom text handling. It's a separate bug from #510910 so I'm opening a new issue for it... Very obscure, so I'm calling this minor for now. ;)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dww’s picture

Title: Global: Custom text using '0' as the value is not rendered » 0 not considered valid alternate or empty text
Assigned: Unassigned » dww
Priority: Minor » Normal
FileSize
2.28 KB

Based on further investigation, we just aren't considering '0' to be valid alternate text nor empty text. Attached patch fixes (and applies cleanly to both DRUPAL-6--3 and HEAD).

dww’s picture

Priority: Normal » Minor
Status: Active » Fixed

From IRC:

merlinofchaos: WFM.

Tested and committed to HEAD and DRUPAL-6--3. Guess this is still minor, even though it's not as minor as I originally thought. ;)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jeffschuler’s picture

Status: Closed (fixed) » Needs review
FileSize
1018 bytes

Backporting this fix to Views 2 did not solve the issue for me.

render()ing the values means that $this->last_render has a string '0' instead of an int 0 -- need to test for this:

-      if ($this->last_render !== 0 || !empty($this->options['empty_zero'])) {
+      if (($this->last_render !== 0 && $this->last_render !== '0') || !empty($this->options['empty_zero'])) {

Patch for 2.x-dev attached. I'm not sure whether this change is necessary for 3.x-dev as well.

btw, #559102: Views thinks that a 0 value is empty even when the box 'Count the number 0 as empty' is unchecked... looks to be a dup of this issue, where folks are still experiencing the issue, (as I was.)

sphopkins’s picture

I have been posting in the other thread #559102: Views thinks that a 0 value is empty even when the box 'Count the number 0 as empty' is unchecked... and I am glad that someone has some ideas here.

I tested this patch on my machine and I do not thing that it worked. Note that I am using it on views 2.7.

I will post any results here

dashton’s picture

I'm having the same issue- applied the patch and it didn't fix the problem. I'll keep looking into it and post what I find.

sphopkins’s picture

Need to verify this but when you apply the patch to 6.2.8 I get a whitescreen....

That and Views 2.8 still does not display '0' at all when this patch is applied (properly as well... for some reason I did not apply it properly hence the whitescreen).

merlinofchaos’s picture

Status: Needs review » Fixed

Patch in #4 looks correct to me, and it does fix the issues I can reproduce. If there are issues that it does not fix, they might be separate, but I don't know how to recreate them to test. I have committed it to all branches.

Aren Cambre’s picture

Subscribe (in case this issue gets more attention later).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

NaX’s picture

Status: Closed (fixed) » Needs work

I have just run into this same issue and the patch did not fix the problem I had.

I have a table view with CCK fields. One of the CCK text fields is sometimes empty. So I set the Empty text option, but it was not displaying the empty text.

After some investigation I found that because I also had the Link this field to its node option set the empty field was rendering empty links.

EG:
<a href="node/115"></a>

When I set the Hide if empty then only does the empty text get displayed.

Is this by design? The way I understand stood things, the un-rendered field is what should be checked for being empty and the hide if empty options remove the field from the display (Label and all, if possible) if empty.

If I understand things correctly maybe the render_text function should also check for empty text.
Hope that all makes sense.

merlinofchaos’s picture

Empty links seems like a different issue than not accepting 0 as empty. Call me crazy.

timbraeckman’s picture

I also have an issue like this. I have matches and when there is no score there is nothing stored in the database. But for some reason views show 0 instead of empty. I want it to show 0 when there is a 0 in the database and nothing when there is nothing in the database. Can anyone tell me how to fix this please?

esmerel’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
Status: Needs work » Closed (fixed)

This has been closed twice; it's a different issue if there's still a problem.