How to prevend duplicates of content in a view?

tr flag

On a multilingual drupal website (version 9.2.10) A block duplicates content on the landing page when 2 of more languages are enabled.

The block shows random published content for a custom content type in a grid system with a cards layout.

Due to 2 extra enabled languages, for example Dutch and German, Dutch content is duplicated and showed 3 times in this views grid now.

This duplication of content didn't appear when the languages where disabled.

Currently the view is rendering language by the selection "interface text language selected for page"

Update current view settings:current view settings Note:

  • under Advanced --> Query settings --> Distinct is enabled
        type: views_query
          disable_sql_rewrite: false
          distinct: true
          replica: false
          query_comment: ''
          query_tags: {  }

View displays duplicates of "Humo Dutch": duplicates of Humo Dutch

beltouche avatar
cn flag
Seeing your current Views config would help find a solution. Undesirable duplication of results is a common problem in Views. (Off the cuff, grouping by language might be of help.)
Joehoe avatar
tr flag
When switching languages the view is showing the right content. Only duplicated. I added some config as an update in the answer. Need of the whole `yml` output?
br flag

It's duplicated because you displaying now all the languages. You need to make sure on a multilingual site, that you list a single language per content in views. The suggested by me, to add a filter with Default translation (= True). Then set the rendering language to the correct type which you need. This will ensure that all contents will be displayed. However, if you have content that is not translated, it will be visible in the original language. If you need to display only the current language you can set the content language filter (Translation language (= interface text language selected for page)) instead of the original, but in this case, there's no fallback language.

Joehoe avatar
tr flag
Hi there, While adding a filter criteria the suggested "Original language" filter didn't work but instead I used the filter criteria "Translation language (= interface text language selected for page)" If you could update this in your answer I can accept your answer as useful.
br flag
Ah yes, because it's called "Default translation (= True)"

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.