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.
It would be useful to have an API function that makes links to search results pages.
(Follow-on from this support request: #1816602: is there a way to make a link to a search result?).
Comment | File | Size | Author |
---|---|---|---|
#1 | 1828280.1.facetapi.api-link-search-results.wip_.patch | 1.46 KB | joachim |
Comments
Comment #1
joachim CreditAttribution: joachim commentedHere's a patch based on the example code.
It has a couple of problems which I don't know how to fix, as I don't know the internals of facetAPI well enough.
Comment #2
cpliakas CreditAttribution: cpliakas commentedjoachim,
Thanks for rolling. This looks pretty good, and I'll try it out. Taking a quick look, I think your first @todo isn't necessary since it is possible that different facets values produce paths if the Facet API Pretty Paths module is being used. So it seems like wasted cycles, but it is necessary. Therefore your code looks good to me.
Regarding the second @todo, you might have to initialize the $options['query'] key to an array if doesn't exist and then merge in the Facet API query string variables. For example, something like the following:
That might do the trick.
Thanks for the patch!
Chris
Comment #3
joachim CreditAttribution: joachim commented> it is possible that different facets values produce paths if the Facet API Pretty Paths module is being used
That may be problematic then -- what happens when multiple facets want to affect the path? Here it's clobbered by each facet until the last one.
For the second problem, I don't think it's the query array that's the problem. It seems to me there's a problem due to getQueryString not knowing there are other facets in the query already and so not increasing the number in the f[N].