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 the same need as in #2060861: Display total count on the title? but cannot use the "Global: Result summary" because I also want to use tokens for the Contextual filters, which do not work there.
Steps to reproduce
- Create a view
- Add a contextual filter
- Set the title to "@total Results for '%1'"
- Add a "Global: Result summary" to the Header of the view and put "@total Results for '%1'"
Expected result
Both the title and the "Global: Result summary" should replace both tokens.
- @total with the number of results
- %1 with the contextual filter
Actual result
- The title replaces the %1 with your contextual, but @total is not replaced.
- The "Global: Result summary" replaces the @total but not the %1
Comment | File | Size | Author |
---|---|---|---|
#7 | views-allow_summary_tokens_in-2583979-7.patch | 4.54 KB | NWOM |
|
Comments
Comment #2
jojonaloha CreditAttribution: jojonaloha at Metal Toad commentedThe attached patch moves the "Global: Result summary" tokens to
views_plugin_style
, handling them with the rest of the tokens intokenize_value()
. In order to remove duplicate code, I removed this fromviews_handler_area_result
, which is almost unneeded now. In order to not break existing views though, I made it extendviews_handler_area_text
since that already calls the style pluginstokenize_value()
method, and set the defaults forviews_handler_area_result
to turn on tokens, which are required now for the summary to work.Comment #3
NWOM CreditAttribution: NWOM commentedI tested this against an older stable version and it worked amazingly. I added @total to the title without problems. Thank you very much!
Comment #4
mrsad CreditAttribution: mrsad at DrupalJedi commentedUpdated patch to latest 7.x-3.x-dev.
Comment #5
ocastle CreditAttribution: ocastle at Full Bundle commentedPatch #4 works well for the title.
However changing the extended class to
views_handler_area_text
causes the 'Global: Result Summary' field to usetext_format
instead oftextarea
. This might cause HTML to be stripped from the output until the field format is updated.I don't think this is ideal when trying to support existing views. I've attached a new patch using the original code but just adjusting to run it though token replacement.
Comment #6
Alexey.Samsonov CreditAttribution: Alexey.Samsonov at DrupalJedi commentedAdapted for latest 3.x-dev
Comment #7
NWOM CreditAttribution: NWOM commented#6 no longer applied to the latest dev or stable. Here is a re-roll against the newest dev.