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?
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.