"Has taxonomy term" contextual filter does not take the language value into account

Created on 25 June 2017, over 7 years ago
Updated 26 March 2023, over 1 year ago

Problem/Motivation

On a multilingual website:

  1. Create an article with a tag, for example in english
  2. Translate the article in french and do not associate the french version with the tag.
  3. Go to the tag page in english
  4. See your article in english: OK, normal
  5. Go to the tag page in french
  6. See your article in french: KO, the french version of the article is not associated with the tag

The problem is due to the taxonomy_index table, the langcode of the node is not stored. So when the contextual filter "Content: Has taxonomy term ID" make a relationship on the table, it includes the node in all the languages.

Proposed resolution

I don't know how the clean way to solve this and as I need something working quickly I made a workaround. I will upload a patch (with a hook_update_n starting at 8300 to not be incompatible with further merged hook_update_n).

The idea is to add a "langcode" column to store the langcode of the node in which the taxonomy term is referenced.

Then adding a new view filter on this column to be able to filter the results to avoid duplication.

Remaining tasks

  1. Code / idea review
  2. Needs tests
  3. Needs proper update path

User interface changes

A new view filter is created: "Taxonomy term: Node language"

Data model changes

Column "langcode" added to taxonomy_index and "langcode" added to the primary key and the ndexes of the table.

🐛 Bug report
Status

Needs review

Version

10.1

Component
Taxonomy 

Last updated about 15 hours ago

  • Maintained by
  • 🇺🇸United States @xjm
  • 🇬🇧United Kingdom @catch
Created by

🇫🇷France Grimreaper France 🇫🇷

Live updates comments and jobs are added and updated live.
  • VDC

    Related to the Views in Drupal Core initiative.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024