[view:title] should take in account overriden title in contextual filters

Created on 20 May 2025, 2 months ago

Problem/Motivation

I use [view:title] to set the Page title in Views Meta tags (Basic tags). In my view (page display) I have a contextual filter and there in "When the filter value IS in the URL or a default is provided" I override the title adding {{ arguments.title }} to some text.
[view:title] doesn't takes in account the new title. Of course I can set the meta tags title as in contextual filter using there {{ arguments.title }} too. It works (subject to cache cleaning even if I am in developer mode with all caches disabled, twig included see https://www.drupal.org/project/metatag/issues/3497684 💬 Usage of the {{ title }} token Active ). But this is not a solution because when the argument is missing It should show the standard title and not the rewritten one.

Steps to reproduce

Set a view with a contextual filter
Use the "When the filter value IS in the URL or a default is provided" option to rewrite the title.
Set meta tags title to [view:title]
Save the view and display the page
Although the displayed title inside the page (h1) obeys to the rewriting, the title in the navigation barre and in the html source tag still has the unchanged title.

Proposed resolution

Refactor the logic of [view:title] so that when a contextual filter rewrites it, it uses the overridden title.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.1

Component

Views integration

Created by

🇫🇷France erwangel

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024