I was trying to use this slider with some fields obtained through relationships and noticed it wasn't working. When comparing the URL with the standard 'widget links' I noticed that the separator between 'points' in the relationship didn't match. For now I am using this hack:

function search_api_ranges_block_view_form($form, &$form_state, $variables) {
  $form = array();
  
  $variables['range_field']= str_replace(':','%3A',$variables['range_field']);

Comments

Anonymous’s picture

Status: Active » Postponed (maintainer needs more info)

Can you explain how to reproduce this? In principle "%3A" is the urlencode() replacement for ":" anyway, so it shouldn't matter.

Or maybe we should use urldecode:

  );
  $form['range-field'] = array(
    '#type' => 'hidden',
    '#value' => urldecode($variables['range_field']),
  );

What do you think?

MrGeneric’s picture

Sorry, I should have explained properly. The %3A gets encoded to %253A which is the same as the separator produced by the widget links facet for fields obtained through a relation. Whether or not this was the intentional separator or likely to change, I am not sure.

Example query strings
before change:
?f[0]=field_average_price%3Aaverage_price_supplier%3A[0 TO 900]
after:
?f[0]=field_average_price%253Aaverage_price_supplier%3A%5B0%20TO%20900%5D

Here, field_average_price was added as a relation.

Steps to reproduce:

  • Add a node reference field to an entity (the referenced node should have a field usable with the range widget)
  • Create an index of the entity you added the node reference to
  • In the fields tab add the node reference field as a relation
  • Add a field obtained through this relation to the index (useable with the range widget)
  • Use this field to create a facet with the range widget
  • Try and filter search results with the resulting facet

Thanks for all your work on this module.

Edit:
I should point out that $variables['range_field'] has the form,
field_average_price:average_price_supplier, in the above example.

mrfelton’s picture

Status: Postponed (maintainer needs more info) » Active

I have this issue to - it's the reason why the slider widget wasn't working for me in [#1350528 even after my patch - and it's also stopping things working in my widget for #1302678: Min/Max for Ranges only updated for first Range Facet. To fix this in my widget, I'm now using the following:

$query = urlencode($variables['range_field']) . ':' . '[' . $min . ' TO ' . $max . ']';

EDIT: Note the use of urlencode on the fieldname.

Anonymous’s picture

Ok, so we should use "rawurldecode()" on the range_field. rawurlencode() as per http://drupal.org/node/1352082#comment-5336828

$query = rawurlencode($variables['range_field']) . ':' . '[' . $min . ' TO ' . $max . ']';

Will have a patch soon.

emorency’s picture

StatusFileSize
new924 bytes

This is a patch for that issue. Please review.

emorency’s picture

StatusFileSize
new620 bytes

Actually, this is the patch for 7.x-1.x version.

Anonymous’s picture

Status: Active » Fixed

Committed to devx.

Status: Fixed » Closed (fixed)

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