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 noticed an issue with the latest dev version of the CTools Views Content module. When a view is created with exposed sorts and the view pane is added to a panel page and you configure the view pane settings in panels, the Sort By and Sort Order dropdowns do not retain the value you select.
Steps to reproduce:
- Create a view with a content pane display.
- Add a few sort criteria and set them as exposed.
- In the view's pane settings section, select "Use exposed widgets form as pane configuration" under Allow Settings.
- Add the view pane to a panel/panelized page.
- In the view pane's settings, select a different value in the Sort By and Sort Order dropdowns, then click Finish.
- Go back into the view pane's settings and you will see that the dropdowns have reverted back to their default values instead of the values you selected in the previous step.
Some additional information that may help narrow down the issue:
- Exposed filters work as expected. The issue is limited to exposed sorts.
- The exposed sort option appears to be saved to the database since previewing or saving and viewing the page shows the view with the correct sort order. However if you go back into the view pane's settings form, the dropdowns do not show the correct value so I think the issue is with reading the current configuration from the database and selecting the correct Sort By/Order values in the dropdowns.
Comment | File | Size | Author |
---|---|---|---|
#29 | views-exposed-sorts-2037469-29.patch | 2.47 KB | cboyden |
| |||
#26 | views-exposed-sorts-2037469-26.patch | 2.43 KB | hswong3i |
|
Comments
Comment #1
Jānis Bebrītis CreditAttribution: Jānis Bebrītis commentedI stumbled across the same issue - we're using views panes and none of sorts would display saved values. I debugged it to views module, filters actually get wrong default values.
Here's patch (for latest 7.x-3.x) I created to solve this issue.
Comment #2
Jānis Bebrītis CreditAttribution: Jānis Bebrītis commentedSomehow I lost the patch, here it is
Comment #3
Jānis Bebrītis CreditAttribution: Jānis Bebrītis commentedchanging status
Comment #4
jlapp CreditAttribution: jlapp commentedThanks Janis, your patch in #2 resolved this issue for me!
Comment #5
dsnopekRTBC +1!
We're using this patch in Panopoly. :-)
Comment #6
guillaumev CreditAttribution: guillaumev commentedJust confirming that this is also working on my side.
Comment #7
dsnopekComment #10
mglamanLooks like a test bot hiccup. Putting back to RTC.
Comment #11
thePanz CreditAttribution: thePanz as a volunteer commentedThe patches in #2 fixes the issue and correctly applies on latest 3.11 release.
Comment #12
spesic CreditAttribution: spesic commentedUpdated #2 to check sort_order property before accessing it to avoid php notice spam. Default to original sort if the property is undefined.
Comment #13
spesic CreditAttribution: spesic commentedComment #14
nbucknor CreditAttribution: nbucknor commentedpatch #12 works for me.
Comment #15
shivneel CreditAttribution: shivneel commentedPatch #12 fixes the issue and correctly applies on 3.11 release for me as well.
Comment #16
dobe CreditAttribution: dobe as a volunteer commentedSo I have been working on similar issues. I am running panopoly so this patch was already applied. But then I started seeing issues with the default "sort_by" & "sort order" not getting applied for exposed sorts.
I found the issue: https://www.drupal.org/node/666870 which is fairly old but for the most part the approach looked good to me over there. I took that patch applied it to this one in addition I fixed the issue where the default sort order wasn't getting applied.
This patch seems to be fixing all my issues.
If this patch is good we need to make sure to give credit for all those found in: https://www.drupal.org/node/666870
Comment #17
humansky CreditAttribution: humansky as a volunteer commented#16 Works like a charm.
Also, for the Panopoly folks, I added a patch here: #2782721: Exposed Views Sort Order Bug
Comment #18
rjdavidson CreditAttribution: rjdavidson commentedRefactored #16 a bit to simplify and clarify the logic.
Comment #20
rjdavidson CreditAttribution: rjdavidson commentedComment #21
rjdavidson CreditAttribution: rjdavidson commentedComment #22
rjdavidson CreditAttribution: rjdavidson commentedComment #24
rjdavidson CreditAttribution: rjdavidson commentedComment #25
darrenwh CreditAttribution: darrenwh as a volunteer and at Investis Digital commentedThis is block of code is quite complex and would benefit with some comments to explain the logic?
Comment #26
hswong3i CreditAttribution: hswong3i commentedUpdate patch due to #2920737: Tidy up tests, coding standards via latest 7.x-3.x-dev
Comment #27
berramou CreditAttribution: berramou commentedThanks
#26 patch work for me
Comment #28
teefars CreditAttribution: teefars commentedThanks hswong3i, #26 works like a charm on latest stable.
Comment #29
cboyden CreditAttribution: cboyden at UC Berkeley Web Platform Services commentedHere's a re-roll of #26 that applies to the latest release 3.25.
Comment #30
djdevinStill works. Setting back to RTBC, we've used this patch in production for 5+ years on hundreds of sites.
Comment #32
DamienMcKennaCommitted. Thank you.
Comment #33
DamienMcKenna