Bug 7620: OPACNoResult, Add keyword to query string
authorLyon3 Team <koha@univ-lyon3.fr>
Thu, 11 Oct 2012 14:12:48 +0000 (16:12 +0200)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Sat, 22 Dec 2012 21:45:31 +0000 (16:45 -0500)
When search failed, this patch gets the keyword(s) and add them
to the string entered by the user to OPACNoResultFound

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
opac/opac-search.pl

index 9239f12..c1870ad 100644 (file)
@@ -239,6 +239,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:'
+            - '<br />Note: You can insert placeholders {QUERY_KW} that will be replaced with the keywords of the query.'
             - pref: OPACNoResultsFound
               type: textarea
               class: code
index 73d2c53..9708176 100755 (executable)
@@ -761,6 +761,16 @@ for (my $i=0;$i<@servers;$i++) {
         }
         # no hits
         else {
+            my $nohits = C4::Context->preference('OPACNoResultsFound');
+            if ($nohits and $nohits=~/{QUERY_KW}/){
+                # extracting keywords in case of relaunching search
+                (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);
+                $nohits=~s/{QUERY_KW}/$query_kw/g;
+                $template->param('OPACNoResultsFound' =>$nohits);
+            }
             $template->param(
                 searchdesc => 1,
                 query_desc => $query_desc,