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 @@ ...@@ -16,6 +16,12 @@
; limit = The maximum number of search results to show in this column; note ; 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. ; that this must be a legal limit value for the chosen search backend.
; (may sometimes require config changes -- e.g. searches.ini, Summon.ini). ; (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 ; All display text is subject to translation and may be added to the language
; .ini files. ; .ini files.
......
...@@ -231,6 +231,18 @@ class AbstractSearch extends AbstractBase ...@@ -231,6 +231,18 @@ class AbstractSearch extends AbstractBase
} }
$rManager = $this->getServiceLocator()->get('VuFind\RecommendPluginManager'); $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) { return function ($runner, $params, $searchId) use ($rManager, $activeRecs) {
$listener = new RecommendListener($rManager, $searchId); $listener = new RecommendListener($rManager, $searchId);
$config = []; $config = [];
......
...@@ -256,8 +256,22 @@ class CombinedController extends AbstractSearch ...@@ -256,8 +256,22 @@ class CombinedController extends AbstractSearch
$query = $this->getRequest()->getQuery(); $query = $this->getRequest()->getQuery();
$query->limit = isset($settings['limit']) ? $settings['limit'] : null; $query->limit = isset($settings['limit']) ? $settings['limit'] : null;
// Disable top/side recommendations but leave noresults active: // Reset override to avoid bleed-over from one section to the next!
$query->noRecommend = 'top,side'; $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 @@ ...@@ -25,6 +25,9 @@
<div class="resulthead"> <div class="resulthead">
<div class="floatleft"> <div class="floatleft">
<? if ($recordTotal > 0): ?> <? if ($recordTotal > 0): ?>
<? foreach (($top = $results->getRecommendations('top')) as $current): ?>
<?=$this->recommend($current)?>
<? endforeach; ?>
<?=$this->transEsc("Showing")?> <?=$this->transEsc("Showing")?>
<strong><?=$this->localizedNumber($results->getStartRecord())?></strong> - <strong><?=$this->localizedNumber($results->getEndRecord())?></strong> <strong><?=$this->localizedNumber($results->getStartRecord())?></strong> - <strong><?=$this->localizedNumber($results->getEndRecord())?></strong>
<? if (!isset($view->skipTotalCount)): ?> <? if (!isset($view->skipTotalCount)): ?>
......
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
<div class="clearfix"> <div class="clearfix">
<div class="pull-left help-block"> <div class="pull-left help-block">
<? if ($recordTotal > 0): ?> <? if ($recordTotal > 0): ?>
<? foreach (($top = $results->getRecommendations('top')) as $current): ?>
<?=$this->recommend($current)?>
<? endforeach; ?>
<?=$this->transEsc("Showing")?> <?=$this->transEsc("Showing")?>
<strong><?=$this->localizedNumber($results->getStartRecord())?></strong> - <strong><?=$this->localizedNumber($results->getEndRecord())?></strong> <strong><?=$this->localizedNumber($results->getStartRecord())?></strong> - <strong><?=$this->localizedNumber($results->getEndRecord())?></strong>
<? if (!isset($view->skipTotalCount)): ?> <? 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