When i create a view of content and add a contextual filter there is the option to reduce duplicates which is great, the contextual filter i am using in my content view is "Has taxonomy term ID".

However, when i create a view of users and add a contextual filter the option to reduce duplicates is not there, which is a problem because i have duplicates, the contextual filter i am using in my user view is "[taxonomy] (field_[taxonomy])".

Should there be a reduced duplicate option or does anyone know of a way i can reduce duplicates.

Thanks.

Comments

ghaddon’s picture

To get around the problem i added this php filter:

<?php
// initialise array
$static[0] = "";
// check if uid is in array
if (in_array($row->uid, $static)) {
     // if in array return true
     return "true";
}
// add uid to array
$static[] = $row->uid;
?>
kip stanning’s picture

StatusFileSize
new16.99 KB

got the same problem with nodes and a contextual filter on terms.

i use a field called "Stichwort" wich is a term reference to the vocabulary "Tags".

i created a relationship to Content: Stichwort and a second relationship using the first one "Taxonomy Term: Content using Stichwort". This allowed me to set a contextual filter "(term from field_stichwort) Taxonomy-term: Name".

this works only half-way through the task: the requested summary is created and the count of results is displayed in parentheses. but duplicates are not reduced, e.g. in the summary you find "Richtlinie (2)" twice (see screenshot).

any ideas would be very much appreciated.

regards from vienna forest
karl

WhiteWinterWolf’s picture

Hello,

Just in case some other may go through the same page, this solves the issue in most cases : in the view details, go in "Advanced" > "OTHER" > "Query settings", then check the box "Distinct".

Views will then add the "distinct" keyword to its SQL request in order to ask the database server to remove any duplicates.

Best regards,
Simon.

dawehner’s picture

@kip stanning
In many cases duplicates in connection with taxonomy terms are a configuration/misunderstanding of the way sql works.
If you want to display taxonomy terms, and you don't use a summary query you want to have a view of terms not of nodes....

couturier’s picture

Status: Active » Closed (fixed)

I've seen comments many places similar to dawehner's above, that duplicates can simply be a misconfiguration problem. See this comment: http://drupal.org/node/345571#comment-1188223

jessZ’s picture

Issue summary: View changes

# 3 worked like a charm. +1 "Advanced" > "OTHER" > "Query settings", then check the box "Distinct".

under the same tab I was wondering what the
"Query Tags
If set, these tags will be appended to the query and can be used to identify the query in a module. This can be helpful for altering queries."
setting meant, got a small error because the default was Array and the error message asked for lower case. I don't think we are using this anyway but i changed it to "array." this should help me clean up quite a few views.

Hello,

Just in case some other may go through the same page, this solves the issue in most cases : in the view details, go in "Advanced" > "OTHER" > "Query settings", then check the box "Distinct".

Views will then add the "distinct" keyword to its SQL request in order to ask the database server to remove any duplicates.

Best regards,
Simon.

abrlam’s picture

Just writing this down for future reference. Hope that helps.

Besides checking "Distinct" in the View setting, check whether module Taxonomy Set Lineage is installed and enabled on your site. If it is, try disabling it and add another node for testing to see if the duplicate issue persists.

Also, try saving the nodes (that produce the duplicates in the view) again and see if it fixes the problem.

*Some clean up work (adjusting the view, disabling violating modules) might be needed.

The following query will get all the taxonomy terms that have been applied to the node specified.

SELECT *
FROM `taxonomy_index`
WHERE (
CONVERT( `nid`
USING utf8 ) LIKE '%{your nid}%'
)
LIMIT 0 , 30
nayanalok’s picture

After spending a lot of time on this I found this in one post.

Edit the view's "Query settings" as follows:

a) Enable "Disable SQL rewriting"; and

b) Disable "Distinct".

This is what has worked for me on my bookshelf view to show distinct products.