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:

  1. Create a view with a content pane display.
  2. Add a few sort criteria and set them as exposed.
  3. In the view's pane settings section, select "Use exposed widgets form as pane configuration" under Allow Settings.
  4. Add the view pane to a panel/panelized page.
  5. In the view pane's settings, select a different value in the Sort By and Sort Order dropdowns, then click Finish.
  6. 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.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jānis Bebrītis’s picture

Project: Chaos Tool Suite (ctools) » Views (for Drupal 7)
Version: 7.x-1.x-dev » 7.x-3.x-dev
Component: Views Content » exposed filters

I 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.

Jānis Bebrītis’s picture

Somehow I lost the patch, here it is

Jānis Bebrītis’s picture

Status: Active » Needs review

changing status

jlapp’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Thanks Janis, your patch in #2 resolved this issue for me!

dsnopek’s picture

RTBC +1!

We're using this patch in Panopoly. :-)

guillaumev’s picture

Just confirming that this is also working on my side.

dsnopek’s picture

Issue tags: +panopoly

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 2: views-exposed-sorts-2037469-1.patch, failed testing.

mglaman’s picture

Status: Needs work » Reviewed & tested by the community

Looks like a test bot hiccup. Putting back to RTC.

Detect a test run failure
Ensure that you can install SimpleTest locally and invoke tests using the command line script.

thePanz’s picture

The patches in #2 fixes the issue and correctly applies on latest 3.11 release.

spesic’s picture

Updated #2 to check sort_order property before accessing it to avoid php notice spam. Default to original sort if the property is undefined.

spesic’s picture

Status: Reviewed & tested by the community » Needs review
nbucknor’s picture

patch #12 works for me.

shivneel’s picture

Patch #12 fixes the issue and correctly applies on 3.11 release for me as well.

dobe’s picture

So 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

humansky’s picture

Status: Needs review » Reviewed & tested by the community

#16 Works like a charm.

Also, for the Panopoly folks, I added a patch here: #2782721: Exposed Views Sort Order Bug

rjdavidson’s picture

Refactored #16 a bit to simplify and clarify the logic.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 18: views-exposed-sorts-2037469-17.patch, failed testing.

rjdavidson’s picture

rjdavidson’s picture

rjdavidson’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 20: views-exposed-sorts-2037469-19.patch, failed testing.

rjdavidson’s picture

Status: Needs work » Needs review
FileSize
3 KB
2.64 KB
darrenwh’s picture

Status: Needs review » Needs work
+++ b/plugins/views_plugin_exposed_form.inc
@@ -220,33 +220,46 @@ class views_plugin_exposed_form extends views_plugin {
+        if (isset($form_state['input']['sort_by'])) {

This is block of code is quite complex and would benefit with some comments to explain the logic?

berramou’s picture

Thanks
#26 patch work for me

teefars’s picture

Thanks hswong3i, #26 works like a charm on latest stable.

cboyden’s picture

Here's a re-roll of #26 that applies to the latest release 3.25.

djdevin’s picture

Status: Needs review » Reviewed & tested by the community

Still works. Setting back to RTBC, we've used this patch in production for 5+ years on hundreds of sites.

  • DamienMcKenna committed 0988535 on 7.x-3.x
    Issue #2037469 by rjdavidson, Jānis Bebrītis, spesic, dobe, hswong3i,...
DamienMcKenna’s picture

Committed. Thank you.

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.