When I change my sort criteria to random, I begin getting repeat displays of the same node in my view. An alphabetical criteria and the random filter turns up 4 version of the same node. When the random sort criteria is removed, it goes back to displaying each node only once. I've attached an export of the view in question. Note that I have "Node:distinct" implemented as one of the filter criteria.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | dealerview_fixed.txt | 4.7 KB | mennonot |
| dealerview.txt | 4.66 KB | mennonot |
Comments
Comment #1
mennonot commentedI've done some experimentation and this problem seems to be tied to the "View Type: " for the page view.
When I switched the view type from Table to Full Node instead of Table View, only one instance of each node appears. But the multiple versions problem described above also appears with the List view
Comment #2
merlinofchaos commentedIf this is the case, then it probably has more to do with the fields in the view than anything else; fields are not computed in the query with a node/teaser view, but they are with a list view.
Since most of your fields are CCK/location, I don't know enough about them to say, but you could probably start eliminating fields and seeing what happens.
I am 100% sure that a random sort by itself can't cause duplicates.
Also, have you tried the distinct filter?
Comment #3
mennonot commentedSo I started out eliminating fields, which didn't make any difference. Then on a whim I tried switching off the "sortable" variable for the fields and suddenly the duplicates disappeared. I narrowed it down to the "Text: Available settings" field: turning off the sortable option for this column fixes the problem.
The only thing unusual about this field is that it is a select list that shows html. Here is the allowed values list:
I guess it might make sense that in constructing a sortable column, these values may have given the views module trouble.
I've attached the new, working, export of the view in case it's of any use.
Comment #4
mediamash commentedis there a solution for double nodes when using the random filter?
Comment #5
onelittleant commentedThe default implementation of the random view sort is problematic for many reasons... it should only be used for views that display a single page or block of results that are different every time the page is refreshed.
If what you want is something more persistent, like getting random results, but in the same order, that don't change from page to page, here's a solution that will give each site visitor, on a per-session basis, a different, repeatable random order of results.
First, implement hook_views_tables and define a sort as follows (you have to define more than just ['sorts'] on a table definition, including 'name' and 'join', but the details don't matter so long as you're not defining fields or filters, but just a single sort with its own handler, see details here: http://drupal.org/handbook/modules/views/api):
Next, define the sort handler function:
Each distinct session will get a distinct random ordering, but always the same random ordering throughout their session. If you want the repeatable randomness to be tied to something other than the session, then use some other number to set the random seed, like the user id for example for randomness tied to each individual user rather than session.
Note: This works in MySQL. I don't know how to set the random seed in PGSql.
Comment #6
merlinofchaos commentedThis will not be fixed in Views 1.