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
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jojonaloha created an issue. See original summary.

jojonaloha’s picture

Status: Active » Needs review
FileSize
5.93 KB

The attached patch moves the "Global: Result summary" tokens to views_plugin_style, handling them with the rest of the tokens in tokenize_value(). In order to remove duplicate code, I removed this from views_handler_area_result, which is almost unneeded now. In order to not break existing views though, I made it extend views_handler_area_text since that already calls the style plugins tokenize_value() method, and set the defaults for views_handler_area_result to turn on tokens, which are required now for the summary to work.

NWOM’s picture

I tested this against an older stable version and it worked amazingly. I added @total to the title without problems. Thank you very much!

mrsad’s picture

Updated patch to latest 7.x-3.x-dev.

ocastle’s picture

Patch #4 works well for the title.

However changing the extended class to views_handler_area_text causes the 'Global: Result Summary' field to use text_format instead of textarea. 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.

Alexey.Samsonov’s picture

Adapted for latest 3.x-dev

NWOM’s picture

#6 no longer applied to the latest dev or stable. Here is a re-roll against the newest dev.