From 850b9ac67c5914cf7c3addb2263c70eab16f5b2a Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Mon, 17 Mar 2008 21:39:48 -0400 Subject: [PATCH] fix for 1610: Redirect to result when opac search returns only one item Signed-off-by: Joshua Ferraro --- catalogue/search.pl | 6 ++++++ opac/opac-search.pl | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/catalogue/search.pl b/catalogue/search.pl index 8ea778d437..01dd3fbede 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -489,6 +489,12 @@ for (my $i=0;$i<@servers;$i++) { my $page = $cgi->param('page') || 0; my @newresults = searchResults( $query_desc,$hits,$results_per_page,$offset,@{$results_hashref->{$server}->{"RECORDS"}}); $total = $total + $results_hashref->{$server}->{"hits"}; + ## If there's just one result, redirect to the detail page + if ($total == 1) { + my $biblionumber=@newresults[0]->{biblionumber}; + print $cgi->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber"); + exit; + } if ($hits) { $template->param(total => $hits); my $limit_cgi_not_availablity = $limit_cgi; diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 41b655d236..3c6275a91c 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -347,6 +347,12 @@ for (my $i=0;$i<=@servers;$i++) { @newresults = searchResults( $query_desc,$hits,$results_per_page,$offset,@{$results_hashref->{$server}->{"RECORDS"}}); } $total = $total + $results_hashref->{$server}->{"hits"}; + ## If there's just one result, redirect to the detail page + if ($total == 1) { + my $biblionumber=@newresults[0]->{biblionumber}; + print $cgi->redirect("/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber"); + exit; + } if ($hits) { $template->param(total => $hits); my $limit_cgi_not_availablity = $limit_cgi; -- 2.39.5