I have made an image gallery using views. I want to create a vote option for each image. I used the Rate module and I've created a rate button which looks something like this

enter image description here

I used the yes/no widget and changed the option to this enter image description here

In my gallery view I've selected the Content:Votes relationship and changed the value type to options and vote tag to normal vote

The problem is multiple copies of the same content appear in the gallery when the votes are increased. How can I fix this issue? or is there any other way to do this?

  • Try with this relationship - Content:Vote Result, Value Type: Points, and Aggregation function: Total Score Oct 14 '14 at 18:05
  • I tried..its not working
    – newbie
    Oct 14 '14 at 18:08

You can do it at least in 4 different ways that I can think of:

  1. You can have a quick fix if you change the show to Content | Teaser or any other display of show: content

  2. You can enable Use aggregation:Yes under Advanced menu.

  3. Check if any of your fields have multiple values, like more than 1 images in your case which is a gallery. and use grouping fields to fix it.

  4. in your multi value field (probably your image field) under Multiple field settings check Display all values in the same row and then beneath the fields, set Display 1 value(s) starting from 0 and you should be good to go.

Update: 5. Use Views Grouping Row Limit module to limit the output of each grouped row.

  • 1. I don't want it to be displayed that way. Cause I have other fields like colorbox for example. Even when I tried it, the duplicate copies were still showing 2. When I did Use aggregation:Yes, its throwing this error SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax
    – newbie
    Oct 14 '14 at 19:44
  • I'm working on 3. and 4.
    – newbie
    Oct 14 '14 at 19:45
  • This is probably a noob question but how do I check if the fields have multiple values
    – newbie
    Oct 14 '14 at 19:50
  • Well did you upload more than 1 file for any of the fields? like your image field? if so, it means it has more than 1 value
    – Sohail
    Oct 14 '14 at 19:56
  • No..I didn't. Only one file's uploaded for each field
    – newbie
    Oct 14 '14 at 19:56

Hmm.. On the right side, go to Advanced, Other, then Query Settings.

Select the checkbox for "Distinct", and click Apply.

According to the help note:

This will make the view display only distinct items. If there are multiple identical items, each will be displayed only once. You can use this to try and remove duplicates from a view, though it does not always work. Note that this can slow queries down, so use it with caution.

There are more options past that if it doesn't work.. making it more strict, for example. But as the help note mentions.. this doesn't always work.

  • That didn't work :(
    – newbie
    Oct 14 '14 at 19:01
  • This kinda never worked for me, even though that it supposed to work, did you ever get this Query Settings working?
    – Sohail
    Oct 14 '14 at 19:37
  • Oh no. :( I've used it before in other queries and it has helped. @Sohail's multi value field sounds promising though!
    – emijayne
    Oct 14 '14 at 20:22
  • If it is not working then select Pure Distinct too. Nov 6 '14 at 4:55

I had to use the Views Distinct module. Added NID to list of fields, exclude from display and then use filter repeat in the Views Distinct Settings. Funny thing is I had to increase the number of items in the pager to more than the actual number of images, else not all show up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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