diff --git a/config/vufind/searchbox.ini b/config/vufind/searchbox.ini index 365da2ad6e1cbf30709bfee9dc9d63a671c2526e..d6f8e48ee8e7999b7e8fdb3f3b2cadba47ca4d56 100644 --- a/config/vufind/searchbox.ini +++ b/config/vufind/searchbox.ini @@ -9,7 +9,10 @@ combinedHandlers = false ; of settings with the following keys: ; ; 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) [CombinedHandlers] type[] = VuFind diff --git a/module/VuFind/src/VuFind/Controller/CombinedController.php b/module/VuFind/src/VuFind/Controller/CombinedController.php index 0aef4b7790b52da024c5238b89eb1e7a9fbf81fd..50fe00b8452b5d7195fe30e5cd8a9e895b830165 100644 --- a/module/VuFind/src/VuFind/Controller/CombinedController.php +++ b/module/VuFind/src/VuFind/Controller/CombinedController.php @@ -245,7 +245,10 @@ class CombinedController extends AbstractSearch return $this->redirect()->toUrl($base . '?' . http_build_query($params)); case 'External': $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: // If parameters are completely missing, just redirect to home instead // of throwing an error; this is possibly a misbehaving crawler that