0

I am using a view to replace the standard Taxonomy Term page (turned on the standard one in Drupal 8.x). I want the Title of the page to be changed from the Name of the term to the Description of the term everywhere it appears, in the Title attribute in the Header but more importantly in the Title that is rendered on the page. I have tried all sorts of tricks in a custom page--taxonomy.html.twig file to no avail.

0

There is an incompatibility to use Description as Title, at least if you use the default settings. Description is a long text field and it possibly contains HTML. Titles are supposed to be plain text only, they are usually "cleaned" against HTML in them.

That said, if you think you have a case where this makes sense, you can try to use the field tokens for the Taxonomy term Description field. But you'll have to make a lot of changes to the Views if you want to do it through the interface and not custom code.

"Taxonomy term" Views is of the "Content" type, not "Taxonomy term" type, so you don't get taxonomy term info out-of-box in there. You have to add a Relationship towards the term in order to get the term info to be available in Views.

So first add the Relationship for your Taxonomy reference field, it will be under "Content" Category, named something like "Taxonomy term referenced from field_tags". You'll probably want to Require it, to exclude all nodes that don't have that taxonomy tag.

Once you have the Relationship you will be able to add the Field "Description" to your views (change the Format to "Fields" if it's "Content"). You can Exclude it from display if you don't want it in the Views results. And recreate the "Content" Format with Fields, add the node Title field etc.

The Title in the "Taxonomy term" Views isn't coming from the Views Title field, it's coming from the Contextual filter "Override title" option. There is also the Header option rendering the Taxonomy term which shows the linked term name and its description below it.

So if you want to change how that behaves, that's where you'll have to make the changes. I don't think you'll be able to have the Description token work in the default "Has taxonomy term" Contextual. You'll have to remove it and add the Contextual for your tags field, possibly for the Description field (I haven't tried it). Then set the title override on that Contextual and adjust the Views Header option.

Since your Contextual is limited to one field, and no longer covers entire site's Taxonomy, you have to be careful to recreate other Taxonomy pages (for other Vocabularies) if you need them. It's always a good practice not to work on the original "Taxonomy term" Views, instead keep it intact and disabled for future reference, and Duplicate into a new Views and work on the Duplicate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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