Marking this critical since it goes against what I view as the intended design of the module and renders certain aspects of the module to "seem" broken.

This issue has been a bit of a ghost with no one really able to explain what was going on in a logical way.

Here are the details... Doing the following

Steps to recreate the scenario

  1. Create a new view of type "Node"
  2. Add an "in between" filter for a numerical value
  3. Expose the filter, give the filter a logical "min" and "max" range, and set it to "Optional" and "Remember".
  4. Add a page display
  5. Save your view

Experiencing the issue

  1. Browse to your view and note what nodes are showing (if any)
  2. Now clear any of the set min/max values and click apply on the filter

    * note the discrepancies between the normal page and the "filtered" list

Explanation

So, this essentially shows that the fields are not "optional." They are required to be between the two min/max values. Suggestion, don't automatically fill the session with these values upon hitting the page display. It is counter-intuitive since their may be nodes that don't contain these values. Another option would be a simple flag to turn the option to "populate the min/max fields with their min/max values" and then not setting it in the session either, unless the user inputs it and submits of course.

I certainly hope this is clear. Please let me know if you have any questions regarding this.

Comments

nicholas.alipaz’s picture

Title: Session data for "in between" filters is not stored intuitively » Optional "in between" filters not really optional

change title

esmerel’s picture

Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

I'm unable to replicate this with 3.x - it behaves exactly as I would expect. When values are removed from the optional filter boxes, ALL nodes then are present.

In 2.x, the minimum and maximum value are always affecting the output. Are you sure you have the right version listed in your report?

nicholas.alipaz’s picture

esmerel, thanks for testing. I am sure of the version number.... But will do some more testing on a vanilla installation when I have a chance. I just got through "hacking/fixing" a solution that would allow it to work on my site. For what it's worth, here is the code that I ended up using to make it work on my site:


function stitch_formalter_init() {
  // an array of our min/max "in between" filters
  $fields = array('field_age_value', 'field_height_int_value');
  if (arg(0) == 'search' && $_SERVER['QUERY_STRING'] != 'q=search') {
    // set all post values for min/max in the session whenever filtering the view, but not on viewing main page display
    foreach ($fields as $field) {
      $_SESSION['stitch_formalter']['custom_search_adv']['post'][$field] = $_REQUEST[$field];
    }
  }
  else if ($_SERVER['QUERY_STRING'] == 'q=search') {
    // check the min/max values against our previously stored ones in the session
    // if they are empty then set to '' else set to the value from the saved session
    foreach ($fields as $field) {
      $_SESSION['views']['custom_search_adv']['default'][$field]['min'] = (empty($_SESSION['stitch_formalter']['custom_search_adv']['post'][$field]['min'])) ?
        '' : $_SESSION['stitch_formalter']['custom_search_adv']['post'][$field]['min'];
      $_SESSION['views']['custom_search_adv']['default'][$field]['max'] = (empty($_SESSION['stitch_formalter']['custom_search_adv']['post'][$field]['max'])) ?
        '' : $_SESSION['stitch_formalter']['custom_search_adv']['post'][$field]['max'];
    }
  }
}
nicholas.alipaz’s picture

Status: Postponed (maintainer needs more info) » Active

By the way, I think the issue stems mostly from when a field does not contain any data, but it is filterable as "in between". They only show when the value is set to nothing.

I will assign it back to you just so you can comment on this part if you have any input on that. So if you test be sure to have a node with a field that has no value in it, you will find it doesn't show in the results until you hit apply for your filter.

esmerel’s picture

Assigned: Unassigned » merlinofchaos

I've managed to confirm that it behaves differently between 2.x and 3.x, so I'm going to have to show [merlinofchaos] and let him read the code and figure out what way it's supposed to be working :)

I was using nid, because it always has a value, since that was easier than creating my own field and populating a bunch of stuff. :) I wouldn't expect a field with no data to ever show in an 'in between', only if there's no filter present.

esmerel’s picture

nicholas.alipaz’s picture

Or perhaps that one is a duplicate of this?

merlinofchaos’s picture

Status: Active » Closed (duplicate)

That one has a patch, so let's mark this the duplicate.