diff --git a/config/vufind/combined.ini b/config/vufind/combined.ini index 17bdc9a1ec7ec4e07b0ea29c8df6c263e98f855d..24823d7999c5b54ff5f52b7890f54c07edd323c0 100644 --- a/config/vufind/combined.ini +++ b/config/vufind/combined.ini @@ -10,6 +10,9 @@ ; combined search in a simplified manner. ; ajax = If true, these results will load via AJAX; otherwise, they will load ; inline (default = false) +; hide_if_empty = If true, this section will be completely suppressed from +; display when an empty result set is returned. Otherwise, +; it will display the standard "no results" message. ; 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. ; (Setting legal limit values may require changing limit_options in diff --git a/module/VuFind/src/VuFind/Controller/CombinedController.php b/module/VuFind/src/VuFind/Controller/CombinedController.php index 354d101b936844856172b584b98c1646b76d3560..4e9cc2188ee7bd2bc4a231fa4714af4d4c88f8a1 100644 --- a/module/VuFind/src/VuFind/Controller/CombinedController.php +++ b/module/VuFind/src/VuFind/Controller/CombinedController.php @@ -95,10 +95,20 @@ class CombinedController extends AbstractSearch $headers->addHeaderLine('Content-type', 'text/html'); $headers->addHeaderLine('Cache-Control', 'no-cache, must-revalidate'); $headers->addHeaderLine('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT'); - $html = $this->getViewRenderer()->render( - 'combined/results-list.phtml', - array('searchClassId' => $searchClassId, 'currentSearch' => $settings) - ); + + // Should we suppress content due to emptiness? + if (isset($settings['hide_if_empty']) && $settings['hide_if_empty'] + && $settings['view']->results->getResultTotal() == 0 + ) { + $html = ''; + } else { + $html = $this->getViewRenderer()->render( + 'combined/results-list.phtml', + array( + 'searchClassId' => $searchClassId, 'currentSearch' => $settings + ) + ); + } $response->setContent($html); return $response; } diff --git a/themes/blueprint/templates/combined/results-ajax.phtml b/themes/blueprint/templates/combined/results-ajax.phtml index 96e9110de9d37628a517fb2d1f1ddbf3d8bb20ed..d717669d166af71325d6e1db850178adcf357532 100644 --- a/themes/blueprint/templates/combined/results-ajax.phtml +++ b/themes/blueprint/templates/combined/results-ajax.phtml @@ -7,7 +7,7 @@ // Set up Javascript for use below: $loadJs = 'var url = path + "/Combined/Result?id=' . urlencode($searchClassId) . '&lookfor=' . urlencode($lookfor) . '";' - . "\$('#combined_" . $this->escapeHtml($searchClassId) . "').load(url);"; + . "\$('#combined_" . $this->escapeHtml($searchClassId) . "').load(url, '', function(responseText) { if (responseText.length == 0) $('#combined_" . $this->escapeHtml($searchClassId) . "').hide(); });"; ?> <h2><?=$this->transEsc($currentSearch['label'])?></h2> <p><?=$this->transEsc("Loading")?>... <img src="<?=$this->imageLink('ajax_loading.gif')?>" /></p> diff --git a/themes/blueprint/templates/combined/results.phtml b/themes/blueprint/templates/combined/results.phtml index a80cff680f32b200793550cf27f096bb0573b6a7..80991ee682c8ea2384241617505a09e387ee802e 100644 --- a/themes/blueprint/templates/combined/results.phtml +++ b/themes/blueprint/templates/combined/results.phtml @@ -48,6 +48,7 @@ <? endif; ?> <?=$this->flashmessages()?> <? foreach ($this->combinedResults as $searchClassId => $currentSearch): ?> + <? if ((!isset($currentSearch['ajax']) || !$currentSearch['ajax']) && isset($currentSearch['hide_if_empty']) && $currentSearch['hide_if_empty'] && $currentSearch['view']->results->getResultTotal() == 0) { continue; } ?> <div class="combinedResult" id="combined_<?=$this->escapeHtml($searchClassId)?>"> <? if (isset($currentSearch['ajax']) && $currentSearch['ajax']): ?> <?=$this->render('combined/results-ajax.phtml', array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch))?> diff --git a/themes/bootstrap/templates/combined/results-ajax.phtml b/themes/bootstrap/templates/combined/results-ajax.phtml index 8cad16495799d1105d9f8eac57cc5c6bf87ee715..34876cae822687033d7c08e6aad7504958a42f68 100644 --- a/themes/bootstrap/templates/combined/results-ajax.phtml +++ b/themes/bootstrap/templates/combined/results-ajax.phtml @@ -7,7 +7,7 @@ // Set up Javascript for use below: $loadJs = 'var url = path + "/Combined/Result?id=' . urlencode($searchClassId) . '&lookfor=' . urlencode($lookfor) . '";' - . "\$('#combined_" . $this->escapeHtml($searchClassId) . "').load(url);"; + . "\$('#combined_" . $this->escapeHtml($searchClassId) . "').load(url, '', function(responseText) { if (responseText.length == 0) $('#combined_" . $this->escapeHtml($searchClassId) . "').hide(); });"; ?> <h2><?=$this->transEsc($currentSearch['label'])?></h2> <p><i class="icon-spinner icon-spin"></i> <?=$this->transEsc("Loading")?>...</p> diff --git a/themes/bootstrap/templates/combined/results.phtml b/themes/bootstrap/templates/combined/results.phtml index 3f55920b07ab735a3efe9776e2f2994822f033b6..3750adb71e07f71993e53e06b3402914072c06c0 100644 --- a/themes/bootstrap/templates/combined/results.phtml +++ b/themes/bootstrap/templates/combined/results.phtml @@ -57,6 +57,7 @@ <div class="row-fluid"> <? $columns = count($this->combinedResults); ?> <? foreach ($this->combinedResults as $searchClassId => $currentSearch): ?> + <? if ((!isset($currentSearch['ajax']) || !$currentSearch['ajax']) && isset($currentSearch['hide_if_empty']) && $currentSearch['hide_if_empty'] && $currentSearch['view']->results->getResultTotal() == 0) { continue; } ?> <div class="span<?=floor(12/$columns)?> combined-list" id="combined_<?=$this->escapeHtml($searchClassId)?>"> <? if (isset($currentSearch['ajax']) && $currentSearch['ajax']): ?> <?=$this->render('combined/results-ajax.phtml', array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch))?> diff --git a/themes/bootstrap3/templates/combined/results-ajax.phtml b/themes/bootstrap3/templates/combined/results-ajax.phtml index 339436f147e29ac53b448137937e840d5aef61c4..455f9c075559b28464350064b555e8fc19cf1adb 100644 --- a/themes/bootstrap3/templates/combined/results-ajax.phtml +++ b/themes/bootstrap3/templates/combined/results-ajax.phtml @@ -7,7 +7,7 @@ // Set up Javascript for use below: $loadJs = 'var url = path + "/Combined/Result?id=' . urlencode($searchClassId) . '&lookfor=' . urlencode($lookfor) . '";' - . "\$('#combined_" . $this->escapeHtml($searchClassId) . "').load(url);"; + . "\$('#combined_" . $this->escapeHtml($searchClassId) . "').load(url, '', function(responseText) { if (responseText.length == 0) $('#combined_" . $this->escapeHtml($searchClassId) . "').hide(); });"; ?> <h2><?=$this->transEsc($currentSearch['label'])?></h2> <p><i class="fa fa-spinner icon-spin"></i> <?=$this->transEsc("Loading")?>...</p> diff --git a/themes/bootstrap3/templates/combined/results.phtml b/themes/bootstrap3/templates/combined/results.phtml index 9da48811badbc01cb8f6c73d7a27af2294da8346..a652ec14d870a4474d79e9fa6e1ed181c4e56f7d 100644 --- a/themes/bootstrap3/templates/combined/results.phtml +++ b/themes/bootstrap3/templates/combined/results.phtml @@ -57,6 +57,7 @@ <div class="row"> <? $columns = count($this->combinedResults); ?> <? foreach ($this->combinedResults as $searchClassId => $currentSearch): ?> + <? if ((!isset($currentSearch['ajax']) || !$currentSearch['ajax']) && isset($currentSearch['hide_if_empty']) && $currentSearch['hide_if_empty'] && $currentSearch['view']->results->getResultTotal() == 0) { continue; } ?> <div class="col-sm-<?=floor(12/$columns)?> combined-list" id="combined_<?=$this->escapeHtml($searchClassId)?>"> <? if (isset($currentSearch['ajax']) && $currentSearch['ajax']): ?> <?=$this->render('combined/results-ajax.phtml', array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch))?> diff --git a/themes/jquerymobile/templates/combined/results-ajax.phtml b/themes/jquerymobile/templates/combined/results-ajax.phtml index 2672a66a12603a27d201410d9f7eea277fefc41a..eaf0b46e08404e4ad4c316757148aa94c7df3400 100644 --- a/themes/jquerymobile/templates/combined/results-ajax.phtml +++ b/themes/jquerymobile/templates/combined/results-ajax.phtml @@ -7,7 +7,8 @@ // Set up Javascript for use below: $loadJs = 'var url = path + "/Combined/Result?id=' . urlencode($searchClassId) . '&lookfor=' . urlencode($lookfor) . '";' - . "\$('#combined_" . $this->escapeHtml($searchClassId) . "').load(url, function() {" + . "\$('#combined_" . $this->escapeHtml($searchClassId) . "').load(url, '', function(responseText) {" + . "if (responseText.length == 0) $('#combined_" . $this->escapeHtml($searchClassId) . "').hide();" . "$('.combinedButton').button(); });"; ?> <h2><?=$this->transEsc($currentSearch['label'])?></h2> diff --git a/themes/jquerymobile/templates/combined/results.phtml b/themes/jquerymobile/templates/combined/results.phtml index 6141a380a84ce96956cb07253bc60216e5a2d3ae..3bd8b746e2690f17e9e2c60debf18b21f2d3e627 100644 --- a/themes/jquerymobile/templates/combined/results.phtml +++ b/themes/jquerymobile/templates/combined/results.phtml @@ -12,6 +12,7 @@ <div data-role="content"> <?=$this->flashmessages()?> <? foreach ($this->combinedResults as $searchClassId => $currentSearch): ?> + <? if ((!isset($currentSearch['ajax']) || !$currentSearch['ajax']) && isset($currentSearch['hide_if_empty']) && $currentSearch['hide_if_empty'] && $currentSearch['view']->results->getResultTotal() == 0) { continue; } ?> <div class="combinedResult" id="combined_<?=$this->escapeHtml($searchClassId)?>"> <? if (isset($currentSearch['ajax']) && $currentSearch['ajax']): ?> <?=$this->render('combined/results-ajax.phtml', array('searchClassId' => $searchClassId, 'currentSearch' => $currentSearch))?>