While working on the Facet API Pretty Facet Paths module, I was wondering if the following code is working for Apache Solr:

function facetapi_pretty_paths_facetapi_facet_info_alter(array &$facet_info, array $searcher_info) {
  foreach ($facet_info as &$facet) {
    // Check for Apache Solr Taxonomy Term fields.
    if(!empty($facet_info['map options']['module_name']) && $facet_info['map options']['module_name'] == 'Taxonomy') {
       $facet['facetapi pretty paths coder'] = 'taxonomy';
      continue;
    }
    // Check for Search API Taxonomy Term fields.
    if (!empty($facet['field type']) && $facet['field type'] == 'taxonomy_term') {
      $facet['facetapi pretty paths coder'] = 'taxonomy';
      continue;
    }
  }
}

The if statement for Apache Solr uses $facet_info instead of $facet. Furthermore a space is missing after the 'if' keyword.

Comments

dasjo’s picture

Assigned: Unassigned » nick_vh

maybe nick can have a look as far as i remember he added this snippet :)

drewmacphee’s picture

100% agree.. this wasn't working until I changed $facet_info to $facet

    if (!empty($facet['map options']['module_name']) && $facet['map options']['module_name'] == 'Taxonomy') {
      $facet['facetapi pretty paths coder'] = $taxonomy_coder;
    }
dasjo’s picture

@drewmacphee: could you provide a patch so we can get this fixed?

drewmacphee’s picture

Excuse me if this is messed up, never actually made a patch before.
Looks right though.

dasjo’s picture

Status: Active » Fixed
StatusFileSize
new733 bytes

your patch looks perfect .... but it didn't apply.

git apply facetapi_pretty_paths-taxonomy_coder_fix-1868576-1.patch 
error: No changes

using the alternate approach actually it gave me a laugh:

patch -p1 < facetapi_pretty_paths-taxonomy_coder_fix-1868576-1.patch 
patch unexpectedly ends in middle of line
patch: **** Only garbage was found in the patch input.

:)

i applied it manually and my git diff would output the same exact file.
but comparing with diff

diff facetapi_pretty_paths-taxonomy_coder_fix-1868576-1.patch facetapi_pretty_paths-taxonomy_coder_fix-1868576-5.patch 
Binary files facetapi_pretty_paths-taxonomy_coder_fix-1868576-1.patch and facetapi_pretty_paths-taxonomy_coder_fix-1868576-5.patch differ

it seems like you are using a different / wrong encoding for your files. maybe you are working on windows? i think you'll need to fix that for future patches, but anyways i committedit, thanks and congrats for your first contribution! :)

Status: Fixed » Closed (fixed)

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