I've just upgraded to 4.7.6 and Views 4.7.x-1.5, and a View that was previously sorting randomly no longer does.
I have two similar views, one of which is still sorting randomly, and the other of which has stopped. The working view is a page teaser view which displays all the nodes in a certain category ("Artists"). The failing one is also a page teaser view, but this one takes an argument ("artists/$arg"), and displays only the nodes in that subcategory.
The second view still works, but it just doesn't randomly sort anymore.
I've attached an export of the non-working view. You can see it at encompassarts.com/artists/soprano
Thanks in advance for your assistance. I thought I had it right, but maybe not.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | views_random.0.patch | 598 bytes | dfletcher |
| artist_category_view.txt | 1.27 KB | mmahoney |
Comments
Comment #1
dfletcher commentedThis issue is caused by the AS alias in the query. Views happily keeps the parenthesis around when building the "AS" part of the query during add_orderby. "SELECT RAND() AS _RAND()" is not valid SQL to mysql, so it chokes on the query.
This simple patch squeezes "(" and ")" out of the $as string before it is appended to the query.
Comment #2
dfletcher commentedI appear to have an older version of views installed. This appears to be fixed in the latest CVS through improved handling of the alias argument. My bad.
Comment #3
merlinofchaos commentedI don't see why this view might be giving you problems. I imported it and after I stripped out the book filter I got it to work okay for me. It's possible it's the book filter.
Also, your url should be just 'artists' not 'artists/$arg' -- $arg should only be used if it's in the middle of the URL, i.e, node/$arg/edit
Comment #4
mmahoney commentedIt wasn't the view, it turns out. I got it working after I realized I had a conflicting taxonomy view. Sorry for the fire drill.
Comment #5
merlinofchaos commented