Skip to content
Snippets Groups Projects
Commit 9f7ef899 authored by Demian Katz's avatar Demian Katz
Browse files

Add %%lookfor%% token support to search forwarding.

parent 090b1aea
No related merge requests found
...@@ -9,7 +9,10 @@ combinedHandlers = false ...@@ -9,7 +9,10 @@ combinedHandlers = false
; of settings with the following keys: ; of settings with the following keys:
; ;
; type[] = "VuFind" for an internal search module or "External" for an external URL ; type[] = "VuFind" for an internal search module or "External" for an external URL
; target[] = Search class ID for "VuFind" type, URL for "External" type ; target[] = Search class ID for "VuFind" type, URL for "External" type; by default,
; the user's search terms will be appended to the end of the URL in
; "External" mode. You may use a %%lookfor%% placeholder string in the
; URL to force the query to be injected at a specific position.
; label[] = Label for this value (subject to translation) ; label[] = Label for this value (subject to translation)
[CombinedHandlers] [CombinedHandlers]
type[] = VuFind type[] = VuFind
......
...@@ -245,7 +245,10 @@ class CombinedController extends AbstractSearch ...@@ -245,7 +245,10 @@ class CombinedController extends AbstractSearch
return $this->redirect()->toUrl($base . '?' . http_build_query($params)); return $this->redirect()->toUrl($base . '?' . http_build_query($params));
case 'External': case 'External':
$lookfor = $this->params()->fromQuery('lookfor'); $lookfor = $this->params()->fromQuery('lookfor');
return $this->redirect()->toUrl($target . urlencode($lookfor)); $finalTarget = (false === strpos($target, '%%lookfor%%'))
? $target . urlencode($lookfor)
: str_replace('%%lookfor%%', urlencode($lookfor), $target);
return $this->redirect()->toUrl($finalTarget);
default: default:
// If parameters are completely missing, just redirect to home instead // If parameters are completely missing, just redirect to home instead
// of throwing an error; this is possibly a misbehaving crawler that // of throwing an error; this is possibly a misbehaving crawler that
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment