Currently this module doesn't play nice with Search API Ranges

It would be great if it did. Not sure if this requires changes in this module, SAR or both.

It currently receives no 'pretty paths' and when one range facet is applied it causes all the facet links to act as if no facet is applied (remove links link to the base search, add links link to the base search + just that one facet).

Comments

Shadlington’s picture

dasjo’s picture

Category: bug » feature

sounds like a valid request. i would support such a patch

dasjo’s picture

with #1431682: Plan & implement pluggability in place that should be pretty straight forward

Anonymous’s picture

Ok, I started working on this.

I have setup a coder override:

/**
 * Implements hook_facetapi_pretty_paths_coders_alter()
 */
function search_api_ranges_facetapi_pretty_paths_facetapi_pretty_paths_coders_alter(&$coders) {
  $coders['ranges'] = array('handler' => array(
      'label' => t('Default ranges paths coder'),
      'class' => 'SearchApiRangesCoderRanges',
    ), );
}

And an info alter:

/**
 * Implements hook_facetapi_facet_info().
 */
function search_api_ranges_facetapi_facet_info_alter(array &$facet_info, array $searcher_info) {
  foreach ($facet_info as &$facet) {
    
    // Check for Search API Ranges fields.
    if (!empty($facet['map options']['field']['key']) && $facet['map options']['field']['key'] == 'price_final') {
      $facet['facetapi pretty paths coder'] = 'ranges';
      continue;
    }
  }
}

I copied facetapi_pretty_paths_coder_default.inc and made it fit my module (added it to search_api_ranges.info file & flushed caches / rebuild registry). So far, this works, my custom coder is in fact called for my range facets!

But now,... I am stuck. I want to achieve this type of URL:

<alias>/<from-value>/<to-value>

...any help? Where should I define this "format"?

Anonymous’s picture

A temporary solution is

<alias>/[<from> TO <to>]

which works, it's being picked up.

I ll have a patch soon.

dasjo’s picture

hi morningtime, thanks for working on this!

But now,... I am stuck. I want to achieve this type of URL:

<alias>/<from-value>/<to-value>

yes, as you might have seen, facetapi pretty paths currently doesn't support values separated by multiple slashes.
this would require a change to fetchParams of the FacetapiUrlProcessorPrettyPaths, as it currently does two "hard-coded" array_pops(), see here

A temporary solution is

<alias>/[<from> TO <to>]

which works, it's being picked up.

I ll have a patch soon.

great!, keep us updated

Anonymous’s picture

Status: Active » Closed (duplicate)
Anonymous’s picture

Issue summary: View changes

Extra info