From 9a76b7f5e9ac6e05fa4c06a3e08dfc8978dbe4e5 Mon Sep 17 00:00:00 2001 From: Lyon3 Team Date: Tue, 12 Jun 2012 18:31:46 +0200 Subject: [PATCH] OPACNoResult, Add keyword to query string When search failed, this patch gets the keyword(s) and add them to the string entered by the user to OPACNoResultFound --- .../prog/en/modules/admin/preferences/opac.pref | 1 + opac/opac-search.pl | 8 ++++++++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index eb74d81..4ca1cb3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -202,6 +202,7 @@ OPAC: - a library select pulldown menu on the OPAC masthead. - - 'Display this HTML when no results are found for a search in the OPAC:' + - '
Note: The placeholder {QUERY_KW} will be replaced with the keywords of the query.' - pref: OPACNoResultsFound type: textarea class: code diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 5f3ad86..7fc67a6 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -736,7 +736,15 @@ for (my $i=0;$i<@servers;$i++) { $template->param(next_page_offset => $next_page_offset) unless $pages eq $current_page_number; } # no hits + # extracting keywords in case of relaunching search else { + (my $query_kw=$query_desc)=~s/ and|or / /g; + $query_kw = Encode::decode_utf8($query_kw); + my @query_kw=($query_kw=~ /([-\w]+\b)(?:[^,:]|$)/g); + $query_kw=join('+',@query_kw); + my $nohits=C4::Context->preference('OPACNoResultsFound'); + $nohits=~s/{QUERY_KW}/$query_kw/g; + $template->param( 'OPACNoResultsFound' =>$nohits); $template->param( searchdesc => 1, query_desc => $query_desc, -- 1.7.2.5