Drupal - Duplicate view results in multi language sites

Drupal - Duplicate view results in multi language sites

One of the problems you may face when converting your single language Drupal website to a multi-language version are the repeated / duplicated pages that appear in several views. This article explains why this happens and how to eliminate all duplicates.

This article explains how to eliminate the duplicate pages that appear in multi-language Drupal site views. The solution was tested on Drupal 8 but works well in previous versions.

Duplicate pages normally appear in:

Banners

Most Popular Lists

Related Content lists

Slideshows

Taxonomy terms

What's new pages

Lists or Tables

Views in general

Types of duplicate pages

There are two types of duplicate results in multi-language website views:

Content that has more than one translation language: All translations of the same content will be displayed by default in most of Drupal views. You don't need to create a view or block for each language your site display, just add some filters (see below) to display only one language.

Relationships that have more than one translation language: In this case, content that has the same translation language may appear more than once. This happens if the view has a relationship (author, for example) that has multiple translations.

The solutions below for the two types of duplicated contents can be applied individually or together to achieve the desired results.

How to configure a view to only display pages with the language of the user interface (filter content translations)

Go to "Structure"->"Views" in the Drupal administration menu.

Find the view that you want to fix and click "Edit".

Add a new filter criteria: "Content"->"Translation Language".

On the configuration window, select the operator "is one of" and then the language "Interface text language for the selected page".

Apply.

Check if there are no more duplicates with different languages. If you see the same language more than once then apply the next solution also.

Configuring the filter for the language in the actual view results

How to eliminate pages of the same language that appear more than once (filter relationship translations)

Go to "Structure"-"Views" in the Drupal administration mode.

Find the view that you want to fix and click "Edit".

On the configuration window, expand the "advanced" menu.

Identify the existing relationships ("author", for example).

In the "fields" group, identify the field connected to the relationships of the previous step.The relationship name is in parenthesis and the field name is at the side (example: (author) User: Name ).

Add a new filter criteria. In the criteria list, look for for the the field name from the last step ("User" for example) and then for the "Translation language" keyword.

On the configuration window, select the operator "is one of" and then the language "Interface text language for the selected page".

Apply.

Identify the relationships. In this case "(author) User".

Look for the user translation language filter criteria. In this case "Translation language from User".