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.
A common use for the results handler is to display the number of results returned by the last query. The text used for this should often differ depending on whether the total is singular or plural. Patch to follow.
Comment | File | Size | Author |
---|---|---|---|
#20 | views-area-results-plural-1793500-20.patch | 3.08 KB | julia.klimovsky |
| |||
#16 | views-area-results-plural-1793500-14.patch | 3.04 KB | SaytO |
| |||
#13 | views-area-results-plural-1793500-interdiff-1_13.txt | 1.3 KB | loopduplicate |
#13 | views-area-results-plural-1793500-13.patch | 2.91 KB | loopduplicate |
#9 | summary-plural-2-nodes.jpg | 66.84 KB | sirtet |
Comments
Comment #1
Darren OhThe attached patch enables the admin to choose which token will trigger the plural format. It also lets the admin choose to display the results area when the view is empty, unless no query has been executed.
Comment #2
Darren OhComment #3
dawehnerThere so no way to select no plural token so this check seems a bit redundant.
This change seems to be unrelated ...
Comment #4
Darren Oh1) It is necessary to check both whether the plural form has been enabled and whether the selected token is plural.
2) 0 is a valid plural format. We should distinguish between 0 results returned and the query not being executed. I agree that this also addresses the separate problem that the "Show even if empty" setting is available but not respected. There is no open issue for that problem, and it does not require a separate patch.
Comment #5
acrollet CreditAttribution: acrollet commentedPatch in #1 applies cleanly and works well for me.
Comment #6
juahoo CreditAttribution: juahoo commented#1 works for me, thanks.
Comment #7
juahoo CreditAttribution: juahoo commentedThis is a good and useful feature. I vote that it be added to Views.
Comment #8
mattcoker CreditAttribution: mattcoker commentedThis is working great for me, recommend merging into Views
Comment #9
sirtetTested on simplytest.me, works great.
Maybe the help-text's could be a bit more clear about the Format plural field being used instead of the default Display Field.
And maybe
Token used to detect the plural format vs.
Token used to select the plural format
See the different Header- text's in the preview-area (darkened by the overlay), singular above, plural below:
Comment #10
dawehnerWe should have at least some documentation of what is going on.
Comment #11
MatthewHager CreditAttribution: MatthewHager at Poetic Systems for Camden commentedWorks for me, recommend merge.
Comment #12
joelpittetIt sounds like D8 has some neat "true" pluralizing for multilingual as other languages have non-binary decisions for the pluralization.
@MatthewHager We can likely get this in D7 if someone documents those lines as @dawehner mentioned in #10 Maybe you want to give it a try?
This likely couldn't be put in D8 in the same way though...
Comment #13
loopduplicateAdded some comments per #10 and #12
Comment #14
Nixou CreditAttribution: Nixou commentedWorks for me since a year now.
It would be nice to merge this and avoid to reapply patch after each security update.
=> RTBC
Comment #16
SaytO CreditAttribution: SaytO at Metadrop commentedAdded an updated patch for the new version of views.
Comment #17
DamienMcKennaThanks @SaytO. Let's see what testbot says.
Comment #18
DamienMcKennaThis looks pretty good, thank you all for working on it.
My one concern is around this line:
+ && !empty($this->view->build_info['count_query'])
It changes the logic every so slightly and I wonder if it should be handled as a separate request.
Comment #19
PhilYPatch #16 by SaytO seems to be working fine on Drupal 7.69 and Views 7.x-3.23
Thanks
Comment #20
julia.klimovsky CreditAttribution: julia.klimovsky at Sitrus Agency commentedReroll patch to version 7.x-3.24
Comment #21
PhilYPatch #20 works with Views 7.x-3.24, thanks.
Comment #22
Darren OhComment #23
mvcPatch #20 works for us too (slightly modified for 7.x-3.20), although I'll note that this doesn't help you if you're inserting multiple tokens, each of which can have a plural or singular form. But that would require far more complexity and this meets the large majority of use cases, so it would be great to have it included.
Comment #24
renatogIt worked here as well. +1 to it
Thank you so much, everyone.
Comment #26
renatogMoved to the dev branch
Comment #27
DamienMcKenna