I have a view where the user can filter by using contextual filters in the URL, like this:

timeline/%year/%month/%day

I then use these contextual filters:

Content: node.field_daterange (year)

Content: node.field_daterange (month)

Content: node.field_daterange (day)

Users can use this path to get all events in a year, e.g:

timeline/1945

Or to get all events on a specific month in a year they can use

timeline/1945/05

Now I want to dynamically build the title of the view. If only the year parameter is used it should the title "Timeline YEAR" and if both year and month is set I want it to have title "Timeline MONTH YEAR".

In the contextual filter, there is an alternative named "Override title" (under the box "When the filter value IS in the URL or a default is provided")

It is written "Override the view and other argument titles. You may use Twig syntax in this field." But how can I now catch back the %year, %month or %day argument to use it in the title?

  • There is a Replacement patterns fieldset below it that you can copy the patterns from. You need to edit each contextual filter and override the title with the pattern that makes sense in each of those contexts. – prkos Nov 12 at 0:28
  • Oh, I see them now - thank you very much! – user11448 Nov 12 at 0:53
up vote 0 down vote accepted

There is a Replacement patterns fieldset below it that you can copy the patterns from. You need to edit each contextual filter and override the title with the pattern that makes sense in each of those contexts.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.