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?).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Status: Active » Needs work
FileSize
1.46 KB

Here'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.

cpliakas’s picture

joachim,

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:


if (!isset($options['query']) || !is_array($options['query'])) {
  $options['query'] = array();
}

$options['query'] += $adapter->getQueryString($facet, $facet_values, 0);

That might do the trick.

Thanks for the patch!
Chris

joachim’s picture

> 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].