-3

On a multilingual site I have a view of all nodes with the following configuration:

  • View type: Page
  • Format: Table
  • Fields: Content (title)
  • Filter criteria: Published nodes
  • Sort criteria: Publishing date (descending)
  • Paging: Show all content
  • Pager link: No
  • Advanced settings: No
  • Rendering language: Default language of the website

My problem

My problem is that some results in the view (some links to nodes) appear twice or more, with some results appearing even five or six times.

The website is otherwise working fine with no errors.


What I have tried to solve this problem

1. Adding a view language criteria

If I try to add a filter criteria based on language, I get four options:

  1. Original language (content)
  2. Translation language (content)
  3. Original language (content revision)
  4. Translation language (content revision)

Thus:

  • I have tried to add the filter criteria Original language (content) were I chose the default (Hebrew) language of the site.
  • I have tried to add the filter criteria Translation language (content) were I chose "Which is not one of (everything)" so there won't be any translation.

None of these approaches helped.

2. Detecting possible SQL table joins

I don't recall ever joining any table with any table but anyway in my website under /admin/structure/views/settings I chose to show a SQL query above previews of a views.

I got the following output above the preview of the discussed view when no language filter criterias existed:

SELECT "taxonomy_index"."created" AS "taxonomy_index_created", "node_field_data"."nid" AS "nid"
FROM
{node_field_data} "node_field_data"
LEFT JOIN {taxonomy_index} "taxonomy_index" ON node_field_data.nid = taxonomy_index.nid
WHERE "node_field_data"."status" = '1'
ORDER BY "taxonomy_index_created" DESC

My question

How to solve my problem?

2
  • 1
    Is “some links to nodes” an entity reference? If so this has been asked many times on this site, and it is because of how joins work in SQL. Search “views reference duplicate”. If not, we need more information.
    – cilefen
    Dec 19, 2023 at 11:43
  • I have added data about possible SQL table joins.
    – jorno
    Dec 20, 2023 at 14:19

2 Answers 2

1

For a multilingual site you need to add a filter for the language. There are different strategies, filter the Translation language (content) by the current language (= Content language selected for page), or filter the Default translation (content) (a flag indicating whether this is the default translation) (= True) and then translate when rendering the view row (in the middle section of the View). The second method is for displaying all nodes one time even if not translated into the current language.

Since you've answered my question in a now deleted comment that your site is multilingual you need this filter to get only one hit per node for nodes with multiple translations (I don't know if you have any). As commented by @cilefen, the other source for duplicate entries are JOINs to other entity tables, for example taxonomy. Enable the display of SQL queries at /admin/structure/views/settings and check for JOINs.

1
0

I wrote in the question:

  • Sort criteria: Publishing date (descending)

But I was wrong and it was actually:

  • Sort criteria: Taxonomy term publishing date (descending)

So, the problem was caused due to me mistakenly choosing the sort criteria "Publishing date" (Taxonomy term") instead just "Publishing date".

Choosing a sort criteria based on a date in which the content was related to a term caused the number of duplications in the view was corresponding to the number of taxonomy terms in the each node.

Replacing Sort criteria: Taxonomy term publishing date (descending) with Sort criteria: Publishing date (descending) solved my problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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