Add new comment

Drupal - Duplicate view results in multi language sites

By Daniel
- Updated 7 years ago
1 comment

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)

  1. Go to "Structure"->"Views" in the Drupal administration menu.
  2. Find the view that you want to fix and click "Edit".
  3. Add a new filter criteria: "Content"->"Translation Language".
  4. On the configuration window, select the operator "is one of" and then the language "Interface text language for the selected page".
  5. Apply.
  6. 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 a filter for the language
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)

  1. Go to "Structure"-"Views" in the Drupal administration mode.
  2. Find the view that you want to fix and click "Edit".
  3. On the configuration window, expand the "advanced" menu.
  4. Identify the existing relationships ("author", for example).
  5. 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 ).
  6. 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.
  7. On the configuration window, select the operator "is one of" and then the language "Interface text language for the selected page".
  8. Apply.
Looking for relationships
Identify the relationships. In this case "(author) User".

 

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

 

Configure the filter for the relationship
Configure the filter for the relationship.

 

Final filter criteria
Final filters for content and for relationships.
The content of this field is kept private and will not be shown publicly.
CAPTCHA
2 + 5 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Protected by Spam Master