Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have what I think is a fairly simple view. I am trying to create a user list with all the users who are authenticated. I am using fields like "User: Last Name". I filter by active users and the address field I added not equal to 0. I then expose a sort on Last Name and a sort on Address. When I change the selection, the list order changes, but I have no idea what order it is in, it certainly is not in order by either field. If I click on any of the field headers, they don't sort properly either. Charles does not come before Alexander ;)
Comment | File | Size | Author |
---|---|---|---|
#10 | 1333932-allow-clicksort-for-exposed-sorts-6.x-3.x-10.patch | 1.05 KB | thedavidmeister |
#8 | 1333932-sort-exposed-clicksort.patch | 725 bytes | Pedro Lozano |
#2 | view_export.txt | 24.78 KB | flightrisk |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedCan you please provide an export of your view? Typically this is some kind of user error, where the tablesort and the regular sort are being combined in a way that doesn't appear to make sense. We can look at an export and see if that kind of thing is happening.
Comment #2
flightrisk CreditAttribution: flightrisk commentedWell you clued me into something. I had no idea there were two different sorts. I *think* I want the regular sort since that is more end user friendly. You expose the sort and they click on it. I did have a table sort set and the regular sort. I unchecked all the sort boxes in the table sort and the address sort works, all the numbers for the addresses ascend correctly. However, Last name still is not sorting correctly. I guess I will delete the regular sort and try a table sort. I didn't want to do that because then I would have to create them again. Drupal needs an "active" checkbox for sorting so you can turn it on and off without deleting it. Attached is my export.
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedInteresting. Override normal sort is on, so that's actually correct.
When you preview the view, there should be an info box that gives the query it generates. (You may need to visit the settings page to enable this). Can you paste the query it generates while the last name sort is failing?
Also, does putting the last name sort in the "Sorts" section have the same behavior as using the table clicksort?
Comment #4
flightrisk CreditAttribution: flightrisk commentedIf I delete the regular sort and use the table click sort instead it works. I had 2 sorts so that my exposed dropdown could search by last name or by address. They are now gone an I went back into the table click sort and had to add titles to the fields that I had no titles for. I then checked the checkboxes for the fields I wanted to sort by and that works perfectly. I may go back add the regular sort fields back and uncheck everything in the table click sort to look at the query that is generated again. But I think I like the click sort now. I'll just include some text above the table explaining to users they can click the headings to sort by that column.
Comment #5
flightrisk CreditAttribution: flightrisk commentedplease delete
Comment #6
dawehnerUpdate status.
Comment #7
Pedro Lozano CreditAttribution: Pedro Lozano commentedThis is still present.
The problem is that if you _expose_ your sort criteria the table clicksort doesn't work.
Comment #8
Pedro Lozano CreditAttribution: Pedro Lozano commentedThis patch fixes the problem by ensuring we respect the priority that the display handler has on building the sort (as seen on views->build()).
What this patch doesn't do:
* Make sure the exposed form default sort value matches the clicksort value.
* It doesn't add an option to make this behavior optional.
Comment #9
Simon Georges CreditAttribution: Simon Georges commentedChanging status, as there is a patch.
Comment #10
thedavidmeister CreditAttribution: thedavidmeister commentedHere's something for 6.x-3.x as I was having the same issue with click sorts in tables (and VBO tables) not working as soon as I exposed a sort on the view.
I'm not totally convinced that what I've done is the best way of handling this as $view->style_plugin->active and $view->style_options['override'] could exist together on a non-table style plugin and mean totally unrelated things leading to weird bugs. Would have been nice if 'override' was 'override_sort' instead but that's life.
I'd love to hear an alternative way of doing this from someone who is actually familiar with the Views code - I've just been dropping backtraces around until I could find where my 'orderby' was being dropped.
Comment #12
thedavidmeister CreditAttribution: thedavidmeister commentedpatch applies fine. Tests failed because it's for 6.x and the issue is 7.x
Comment #13
tim.plunkettI think the D7 fix looks sane. I opened a D8 issue for it: #2014745: Exposed sorts break custom style plugin sorting
I'd say #8 is RTBC.
Comment #14
dawehnerYes this patch makes sense, but couldn't you also just configure "overide" in the table settings?
Comment #15
dawehnerThank you for the patch and the manual testing.
Committed and pushed to 7.x-3.x
Comment #16
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe Drupal 6 branch is no longer supported, please check with the D6LTS project if you need further support. For more information as to why this issue was closed, please see issue #3030347: Plan to clean process issue queue