Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a node display with a "content statistics: total views" field. It's set for "thousand marker = comma" and "format plural: 1 view, @count views".
If the number is over a thousand it will show "1 view" instead of "1280 views" for example.
When I set the "thousand marker = none" it will show "1280 views" correctly. Same issue with "space" or "apostrophe". "Decimal" however works correctly ...
Comments
Comment #1
rich.3po CreditAttribution: rich.3po commentedAlso getting this problem. It also seems that if the node views go over 1999 the problem goes away
Comment #2
mikeskull CreditAttribution: mikeskull commentedGuys, after some debugging it seems the problem is in core or at least with what the views numeric handler is passing to core (format_plural)
At the top of format_plural is:
if you print $count when you have a comma seperator itll return 1,001 this is ==1 but is not === 1 so either core has to change to check on type and value or view handler has to passs an actual number.
Problem is on line 125 of views_handler_field_numeric.inc.
Comment #3
mradcliffeI don't think there is a good way to solve this issue without rewriting the entire render function, or doing an API breaking hack that simply concatenates the value and the format plural string (without the value). I don't see any way of making this change that won't break people's views who may be using plural formatting.
The summary of the bug is that the separator configuration is incompatible with precision or plural formatting.
This also applies to Drupal 8, which is a core issue now.
Comment #4
mradcliffeOn second thought, I think this is probably a bug in Drupal core with format_plural(). Especially if it supports 10,000, but not 1,001.
Comment #5
Jan van Diepen CreditAttribution: Jan van Diepen commentedCame across the issue and I need it fixed or I need a patch which I can access for an installation profile.
Here's a quick fix that won't break any existing views.
This patch was sponsored by NDITech, the technical department of the National Democratic Insitute.
Comment #6
Jan van Diepen CreditAttribution: Jan van Diepen commentedSorry, I put a wrong patch.
Here's the correct patch.
Comment #7
Jan van Diepen CreditAttribution: Jan van Diepen commentedComment #8
saurabh.dhariwal CreditAttribution: saurabh.dhariwal at AddWeb Solution Pvt. Ltd. commented#6 Patch is working fine with 7.x-3.13 but for 7.x-3.14 patch is not working. Changes would not be reflected without applying patch.
Comment #9
saurabh.dhariwal CreditAttribution: saurabh.dhariwal at AddWeb Solution Pvt. Ltd. commentedComment #10
mradcliffeIf there is an issue with the patch in #6 when applying to "7.x-3.x" branch, then the issue should be changed to "Needs work". The "Reviewed & tested by the community" status should be used when a patch is ready to be committed. It does not seem from your comment that the patch is ready to be committed.
If the patch applies to 7.x-3.x and fixes the issue, maybe change the issue to RTBC. If not, then the issue should be in Needs Work.
Comment #11
silvi.addweb CreditAttribution: silvi.addweb at AddWeb Solution Pvt. Ltd. commentedPFA patch
Comment #12
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 2 year old patch in #11 to views_handler_field_numeric.inc does not apply to the latest views 7.x-3.x-dev and if still relevant needs to be rerolled.
Comment #13
ciss CreditAttribution: ciss as a volunteer commented@Chris2 What you're doing here may actually cause harm. In the above case you've indiscrimenately hidden all files from #11, making #6 the most recent patch at the top of the issue.
Please go through all issues that you've updated over the past several days (weeks?) and unhide any files that were hidden by your script.
Comment #14
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedUnderstood, I was doing this manually but I can go back and edit.
Comment #15
ciss CreditAttribution: ciss as a volunteer commentedThank you. If you need to review your comments, I've created a small online helper.
Comment #16
Andrew Answer CreditAttribution: Andrew Answer as a volunteer commentedPatch rerolled.
Comment #17
Andrew Answer CreditAttribution: Andrew Answer as a volunteer commentedWrong patch attached previously, this is right (from #6).