The Gitlab instance will be restarted on Monday April 28th at 2AM. There will be a short interruption of service.

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

Allow top recommendations to display (and be independently configured) in combined search.

- Resolves VUFIND-1095
parent 3e001bcf
No related merge requests found
......@@ -16,6 +16,12 @@
; limit = The maximum number of search results to show in this column; note
; that this must be a legal limit value for the chosen search backend.
; (may sometimes require config changes -- e.g. searches.ini, Summon.ini).
; include_recommendations = If set to true, standard 'top' recommendations will be
; displayed at the top of the column. If set to an array
; of recommendation settings (as per searches.ini), the
; specified recommendations will be loaded into the top
; area of the column. If set to false, recommendations
; will be suppressed (default).
;
; All display text is subject to translation and may be added to the language
; .ini files.
......
......@@ -231,6 +231,18 @@ class AbstractSearch extends AbstractBase
}
$rManager = $this->getServiceLocator()->get('VuFind\RecommendPluginManager');
// Special case: override recommend settings through parameter (used by
// combined search)
if ($override = $this->params()->fromQuery('recommendOverride')) {
return function ($runner, $p, $searchId) use ($rManager, $override) {
$listener = new RecommendListener($rManager, $searchId);
$listener->setConfig($override);
$listener->attach($runner->getEventManager()->getSharedManager());
};
}
// Standard case: retrieve recommend settings from params object:
return function ($runner, $params, $searchId) use ($rManager, $activeRecs) {
$listener = new RecommendListener($rManager, $searchId);
$config = [];
......
......@@ -256,8 +256,22 @@ class CombinedController extends AbstractSearch
$query = $this->getRequest()->getQuery();
$query->limit = isset($settings['limit']) ? $settings['limit'] : null;
// Disable top/side recommendations but leave noresults active:
$query->noRecommend = 'top,side';
// Reset override to avoid bleed-over from one section to the next!
$query->recommendOverride = false;
// Always leave noresults active (useful for 0-hit searches) and
// side inactive (no room to display) but display or hide top based
// on include_recommendations setting.
if (isset($settings['include_recommendations'])
&& $settings['include_recommendations']
) {
$query->noRecommend = 'side';
if (is_array($settings['include_recommendations'])) {
$query->recommendOverride
= ['top' => $settings['include_recommendations']];
}
} else {
$query->noRecommend = 'top,side';
}
}
}
......@@ -25,6 +25,9 @@
<div class="resulthead">
<div class="floatleft">
<? if ($recordTotal > 0): ?>
<? foreach (($top = $results->getRecommendations('top')) as $current): ?>
<?=$this->recommend($current)?>
<? endforeach; ?>
<?=$this->transEsc("Showing")?>
<strong><?=$this->localizedNumber($results->getStartRecord())?></strong> - <strong><?=$this->localizedNumber($results->getEndRecord())?></strong>
<? if (!isset($view->skipTotalCount)): ?>
......
......@@ -25,6 +25,9 @@
<div class="clearfix">
<div class="pull-left help-block">
<? if ($recordTotal > 0): ?>
<? foreach (($top = $results->getRecommendations('top')) as $current): ?>
<?=$this->recommend($current)?>
<? endforeach; ?>
<?=$this->transEsc("Showing")?>
<strong><?=$this->localizedNumber($results->getStartRecord())?></strong> - <strong><?=$this->localizedNumber($results->getEndRecord())?></strong>
<? if (!isset($view->skipTotalCount)): ?>
......
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