diff --git a/themes/bootstrap5/templates/search/results.phtml b/themes/bootstrap5/templates/search/results.phtml index d1c16e65e1e..2e8baf59209 100644 --- a/themes/bootstrap5/templates/search/results.phtml +++ b/themes/bootstrap5/templates/search/results.phtml @@ -1,11 +1,9 @@ results->getUrlQuery()->isQuerySuppressed() ? '' : $this->params->getDisplayQuery(); - $headTitle = $this->slot('head-title') - ->get($this->translate('Search Results') . (empty($lookfor) ? '' : " - {$lookfor}")); - $this->headTitle($headTitle); + // Normally we would assign the title to its slot and set $this->headTitle here + // Instead we will do so at the end of the file so we can capture errors and no result messages // Set up search box: + $lookfor = $this->results->getUrlQuery()->isQuerySuppressed() ? '' : $this->params->getDisplayQuery(); $this->layout()->searchbox = $this->context($this)->renderInContext( 'search/searchbox.phtml', [ @@ -23,7 +21,8 @@ ); // Set up breadcrumbs: - $this->breadcrumbs()->add($headTitle, active: true); + $breadcrumb = $this->translate('Search Results') . (empty($lookfor) ? '' : " - {$lookfor}"); + $this->breadcrumbs()->add($breadcrumb, active: true); // Set up search controls (avoiding unnecessary rendering): if (!$this->slot('search-controls')->isset()) { @@ -50,7 +49,7 @@ $this->assetManager()->appendScriptString('var multiFacetsSelection = "' . $this->multiFacetsSelection . '";'); ?> -

escapeHtml($headTitle)?>

+

escapeHtml($breadcrumb)?>

results->getResultTotal()) > 0): // only display these at very top if we have results ?> @@ -132,3 +131,13 @@
+layout()->srmessage was initialized when showing.phtml was rendered, + // and it might have been altered if results were empty. However, it contains + // HTML tags like as well as encoded entities that we need to tidy. + $headTitle = html_entity_decode(strip_tags($this->layout()->srmessage), ENT_QUOTES | ENT_HTML5, 'UTF-8'); + $headTitle = $this->slot('head-title')->get($headTitle); + $this->headTitle($headTitle); +?> \ No newline at end of file