Hi,
I like the breadcrumb trail feature based on active facets. Problem is the URL encoding can lead to broken links. For example, I have an entity with a field called "Category" and is a taxonomy term reference. Indexing this field with Search API gives facet links like:
/search?f[0]=category%3Aname:Apple
The facet is actually category:name, but must be written with a filter in the URL like: category%3Aname:Apple
The breadcrumb code in url_processor_standard.inc does not take this into account. It gives URLs like:
/search?f[0]=category%3Aname%3AApple
...which breaks the filter (it does nothing). So the difficult step comes down to this line 87 in setBreadcrumb()_
$query[$this->filterKey][] = $item['field alias'] . ':' . $item['value'];
In my case the field alias is 'category:name' which ends up correctly as 'category%3Aname', but the ':' is incorrectly jumbled up as well in the l() function, so the link does not work.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | rawurlencode_rangefield-1344076-5.patch | 924 bytes | emorency |
| #3 | 1352082-3.patch | 737 bytes | Anonymous (not verified) |
Comments
Comment #1
Anonymous (not verified) commentedMaybe one solution is to rewrite facet links to:
category[name]:Apple instead of category%3Aname:Apple
?
Comment #2
Anonymous (not verified) commentedHa, the solution is easier than I thought:
Just urlencode() the field alias and it works!
Comment #3
Anonymous (not verified) commentedPatch attached.
Comment #4
mrfelton commentedDoes the job for me. Thanks!
Comment #5
cpliakas commentedThe theory of this makes sense, and I definitely want to test it out. Marking as "needs work" because I think we should be using drupal_encode_path() instead of urlencode.
Thanks for the contribution,
Chris
Comment #6
cpliakas commentedPutting on the low hanging fruit list.
Comment #7
Anonymous (not verified) commentedSo we should use rawurlencode() instead of urlencode()?
http://stackoverflow.com/questions/996139/php-urlencode-vs-rawurlencode
Comment #8
cpliakas commentedIt's Drupal best practices to use
rawurlencode()in favor orurlencode(), so that is the direction we should go. Thedrupal_encode_path()function usesrawurlencode()but doesn't encode forward slashes for aesthetic reasons. The more I think about it the forward slashes would need to be encoded in the off chance that the facet name contains them. If we switch torawurlencode()then this patch is RTBC.Thanks,
Chris
Comment #9
cpliakas commentedCommitted at http://drupalcode.org/project/facetapi.git/commit/610fc7f with
urlencode()switched torawurlencode().Congrats on becoming the 18th committer to Facet API!
Comment #10
emorency commentedSorry, wrong issue see http://drupal.org/node/1344076