From f565068db15600e1f77456a5d5292feedd6be470 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 15 Oct 2018 21:38:36 +0100 Subject: [PATCH] Include search term and 'no results' message in search result --- blocks/ORB/Search.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/blocks/ORB/Search.pm b/blocks/ORB/Search.pm index c145c38..2aad4d8 100644 --- a/blocks/ORB/Search.pm +++ b/blocks/ORB/Search.pm @@ -75,6 +75,7 @@ sub _build_recipe { }); } + # Summarise the time my $time = (($recipe -> {"preptime"} // 0) + ($recipe -> {"cooktime"} // 0) ) * 60; @@ -109,11 +110,15 @@ sub _build_search_results { searchmode => 'any', original => $origonly); - # And build the template fragments from that list + my $list = join("", map { $self -> _build_recipe($_) } @{$recipes}); + $list = $self -> {"template"} -> load_template("search/empty.tem") + unless($list); + return ($self -> {"template"} -> replace_langvar("SEARCH_TITLE", { "%(page)s" => "ALL" }), $self -> {"template"} -> load_template("search/content.tem", { "%(page)s" => "ALL", - "%(recipes)s" => join("", map { $self -> _build_recipe($_) } @{$recipes}), + "%(term)s" => $term, + "%(recipes)s" => $list, }), $self -> {"template"} -> load_template("search/extrahead.tem"), $self -> {"template"} -> load_template("search/extrajs.tem")