We ran into an issue with Panopoly where the facet path was being incorrectly returned. In our specific case we were using panels to override the search results page at the path "search/site/%keyword". After performing a search the facet blocks all link to "search/site" instead of maintaining the keyword in the path. This is because of menu_get_item fallback option in search_api's getSearchPath() method.
I think the assumption here is that the keys URL param will always be passed, which is not necessarily the case. Additionally, it would seem that using the request_path method here is preferable, as it maintains any URL params which may have been passed.
Here's a patch which converts the menu_get_item() call to use request_path. This fixes the issue for our needs.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 1827272-request-path-7.patch | 596 bytes | populist |
| #1 | 1827272-request-path.patch | 596 bytes | beeradb |
Comments
Comment #1
beeradb commentedComment #2
baldwinlouie commentedI too am facing this issue. The patch above does in fact fix this problem.
Comment #3
populist commentedI tested this patch and also found it to solve the problem described in the original issue. At issue here is that $item['href'] will only return the non-argumentative part of the path. but using request_path() gets the full path.
Comment #4
drunken monkeyThis change was introduced in #1777710: Remove dependency on $_GET['q'] for determining base paths. I'll ask that issue's creator if this would also work for him. Otherwise we'll have to come up with a more clever way of doing this …
Comment #5
aaronbaumanrequest_path() is the way to go.
RTBC++
closed 2 other issues as duplicates on this one:
#1829638: FacetAPI facet URLs don't include search terms from search page
#1817360: search facets link to wrong URL
Comment #6
HakS commentedThis change does not work for multilingual paths, it returns:
instead of
Curiously, it works with $_GET['q'].
Comment #7
populist commentedHow about using current_path()? Patch attached.
Comment #8
dasjosorry folks, i'm the one to blame for getting that change into search_api. it was due to an attempt to clean up our code for facetapi_pretty_paths: #1777714: Don't modify the query path
i don't have a clear plan on how to approach this problem, but the most important to me seems ensuring that search_api has a reliable base path that works for all scenarios. on my radar these are some factors that play into the game right now:
Comment #9
drunken monkeyCould everyone please test the patch in #7?
If no solution is found which fits all cases, I guess we can just take the approach that fits the most and urge developers with other cases to manually set the facet base path via the
search_api_base_pathoption.@ HakS: Is there an easy way to detect and fix this case? If
request_path()works in all other cases, maybe we should just include the workaround for the one exception – especially if it's one that's more or less core functionality.Comment #10
wwhurley commentedTested patch #7 and it works for us.
Comment #11
beeradb commented#7 works for me as well.
Comment #12
dasjo@drunken monkey:
search_api_base_pathhelps when mapping outgoing links, do you have an idea if/how we could handle mapping them when incoming? (see #1468922: URL aliases require workaround).Comment #13
drunken monkeyJust realized that
current_path()does nothing more than return$_GET ['q'], so this would essentially just be a revert of #1777710: Remove dependency on $_GET['q'] for determining base paths. But as this seems to work for everyone (except the Pretty Facets Paths module) and the current state introduces several problems, I guess we should just do this.Sorry, Josef, you'll have to find another solution for this. It's annoying how hard this is to do (right), but I guess it can't be helped for now.
And no, sorry, I also can't think of another solution than doing nasty things in
hook_url_inbound_alter()… Maybe that's what you'll have to stick with for now. Maybe something better will come up in D8 …Anyways, committed this now, with just using
$_GET['q']again (for clarity).Comment #14
gabb commentedMay be, I opened another issue for the same problem ... Sorry
#1849464: clicking on facet show no result
aplyed patch #7
work for us. Thanks.
Comment #15
agileadam#7 applied cleanly and corrected the problem for me. Thank you.
Comment #16
sun-fire commented#7 fix the url bug, but breaks url's in current search block for active facets (disable facet links) - they have the current url and don't work.
Comment #17
khiminrm commentedHi! I've the same as in #16 plus the breadcrumbs on the search page don't contain search keyword.
Comment #18
dasjoad #15, #16: i think best would be opening a follow up issue with a more detailed description of the search related modules your are using & what worked in which version and what doesn't now.
Comment #19
khiminrm commented@dasjo, Yes you are right. The problem with the module facetapi pretty paths. When I turned it off the links in current search block and in breadcrumbs work. Thanks for advice.
Comment #20
dasjoif you are having trouble in combination with the Facet API Pretty Paths module, please see this issue:
#1861786: Fix base path issues