Given you create a View that has a Content Pane display with an exposed sort and you've configured the "Allow settings" to enable "Use exposed widgets form as pane configuration" - when you add that pane and select a "Sort by", it will get correctly saved and used when displaying that pane. However, if you edit the settings on the pane again, the "Sort by" field will revert to the first value rather than the one that got saved.
This was discovered in Panopoly per this issue #2153291: The "Sort by" won't save in the "Content list" widget (switch from ctools patch to views patch).
I'll attach a patch to fix in a moment!
Comment | File | Size | Author |
---|---|---|---|
#8 | 2153811-8-views_pane_exposed_sort_by.patch | 990 bytes | andrewmacpherson |
#4 | 2153811-4-views_pane_exposed_sort_by.patch | 982 bytes | stella |
#2 | ctools-views-pane-sort-by-2153811-2.patch | 695 bytes | dsnopek |
#1 | ctools-views-pane-sort-by-2153811-1.patch | 639 bytes | dsnopek |
Comments
Comment #1
dsnopekAttach is attached. Please let me know what you think!
Comment #2
dsnopekAck! New version that will actually check if there is a value before setting it. :-)
Comment #3
stella CreditAttribution: stella commentedJust applied the patch from #2 and it works perfectly. It's a fairly simple patch so marking as RTBC.
Comment #4
stella CreditAttribution: stella commentedActually the same issue happens to the sort_order setting as well. Updated patch attached.
Comment #6
dsnopekActually, I didn't experience this problem with the sort order - it works fine for me for some reason. :-/
Also, here is an alternative patch that also fixes this problem, but it's a patch to Views rather than CTools:
https://drupal.org/comment/7993367#comment-7993367
I haven't had a ton of time to look into it, but I suspect that fixing this in Views is the right way to go...
Comment #7
dsnopekI think the Views patch is actually more appropriate, since Views is the source! I tested this Views patch which is what we're now using in Panopoly: #2037469: Exposed Sort By and Sort Order view pane settings not retained
Comment #8
andrewmacpherson CreditAttribution: andrewmacpherson commentedRe-roll of the patch in comment #4.
Agreed, patching in views module is probably better, so leaving this marked as duplicate.
However we were already using the patch from comment #4, so I've included this re-roll, makes our module updates simpler.
This patch has no logic changes, just fixes the a/b addressing pre-amble.
Comment #9
Jorrit CreditAttribution: Jorrit at nCode for DOM Digital Online Media GmbH commentedPersonally I prefer #8 over the views patch because it is only a problem when using ctools and views so fixing it in ctools seems more reasonable. Also, the patch proposed for views accesses
$form_state['input']
in the form alter method which I consider a code smell, it is not a variable that should be accessed by form code in my opinion.views_content_views_panes_content_type_edit_form()
already sets#default_value
on the exposed filter form elements, so setting this on the exposed order/sort seems to be not too inappropriate.