Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I needed to understand myself, so created this patch to save other the trouble. Patch adds to the README 5 example of different ways to craft a url.
Comment | File | Size | Author |
---|---|---|---|
#4 | 1217702--document-range-facet-3.patch | 2.81 KB | drunken monkey |
#3 | README.txt | 5.5 KB | drunken monkey |
#1 | 1217702--document-range-facet-1.patch | 2.38 KB | drunken monkey |
document-range-facet.patch | 2.26 KB | amitaibu | |
Comments
Comment #1
drunken monkeyAh, thanks, good idea! Most people first encountering this have been confused up to now, and I haven't really done a good job of clearing up that confusions. So maybe this will help.
However, regarding the content: Have these really worked for you? As far as I can tell, only the last example is correct, although I can imagine some of the others working as the module tries to find a reasonable fallback. Sorry to put you through the whole guesswork, it really seems I need better documentation. :-/
The attached patch should contain correct examples, I've also changed some formulations. Also, I don't think listing the direct URL is the best way to go, as the URL escaping (which also would have to be applied to the brackets, to be completely correct) makes it rather hard to read. On the other hands, we can't really count on all site builders knowing about
url()
/l()
, right? So maybe a mixed version? Even people not knowing the functions might be reliefed to see the unescaped values, too.On a different note, #1182614: Integrate with Facet API will soon change the way facets are handled. The syntax for them will probably stay the same, though, so probably only minor corrections will be necessary. However, it will have to be moved to another file, as the whole Facets module will later be removed (after a transitional period of some months).
Comment #2
amitaibu> Have these really worked for you? As far as I can tell, only the last example is correct
They actually do, I did it actually based on reading search_api_facets_search_api_query_alter() and _search_api_create_filter_name().
Indeed your example is more clear, and it's a good idea to document how to use url/ l().
I think we should also mention the possibility of "any" (i.e.
+ $options['query']['filter']['field_price'][] = '"*';
)Comment #3
drunken monkeyThe filter should actually be
'(* *)'
, I think. I don't know why these should work for you, especially after looking at the code.As written in my patch, the possible values for filters are listed in the documentation of
SearchApiFacetsQueryInterface::execute()
, in the .api.php file.Comment #4
drunken monkeyOops.
Comment #5
amitaibuI'll revisit my code on Sunday, to see how come it worked. Anyway, your patch looks good and clear.
Comment #6
drunken monkeyI guess it doesn't really matter. The correct versions work fine, as far as I can tell, and as the behaviour of incorrect filters can be seen as unspecified, I guess it's alright if they, for some reason, work too. *shrug*
Anyways, thanks for the suggestion! Committed.
I hope I could also help you a little with your understanding of facets and their URLs. Feel free to ask if things are still unclear.