Bug 35728: Add ability to NOT redirect to result when search returns only one record

This enhancement adds a new system preference RedirectToSoleResult. By default it is enabled, which matches current behaviour - to redirect to the detail page if it is the only search result.

To test:

1) Apply the patch, install database updates, restart services.
2) Go to Koha Administration -> Global system preferences. The RedirectToSoleResult system preference is in the Searching tab. Confirm it is enabled (set to "Redirect") by default.
3) Conduct a catalogue search on the staff interface that you know will return a single result. Confirm you are redirected to the detail page.
4) Do the same search on the OPAC. Confirm you are redirected to the detail page.
5) Go back to the system preferences and disable the RedirectToSoleResult system preference by setting it to "Don't redirect"
6) Do the searches again on the staff interface and OPAC. Confirm you are NOT redirected to the detail page, and the search results page shows as expected.

Sponsored-by: Education Services Australia SCIS
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Aleisha Amohia 2024-01-08 23:04:25 +00:00 committed by Katrin Fischer
parent 6d5d204d03
commit fc8bf12e97
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
2 changed files with 19 additions and 14 deletions

View file

@ -610,19 +610,20 @@ for (my $i=0;$i<@servers;$i++) {
}
## If there's just one result, redirect to the detail page unless doing an index scan
if ($total == 1 && !$scan) {
if ( $total == 1 && !$scan && C4::Context->preference('RedirectToSoleResult') ) {
my $biblionumber = $newresults[0]->{biblionumber};
my $defaultview = C4::Context->preference('IntranetBiblioDefaultView');
my $views = { C4::Search::enabled_staff_search_views };
if ($defaultview eq 'isbd' && $views->{can_view_ISBD}) {
my $defaultview = C4::Context->preference('IntranetBiblioDefaultView');
my $views = {C4::Search::enabled_staff_search_views};
if ( $defaultview eq 'isbd' && $views->{can_view_ISBD} ) {
print $cgi->redirect("/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=$biblionumber&found1=1");
} elsif ($defaultview eq 'marc' && $views->{can_view_MARC}) {
} elsif ( $defaultview eq 'marc' && $views->{can_view_MARC} ) {
print $cgi->redirect("/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=$biblionumber&found1=1");
} elsif ($defaultview eq 'labeled_marc' && $views->{can_view_labeledMARC}) {
print $cgi->redirect("/cgi-bin/koha/catalogue/labeledMARCdetail.pl?biblionumber=$biblionumber&found1=1");
} elsif ( $defaultview eq 'labeled_marc' && $views->{can_view_labeledMARC} ) {
print $cgi->redirect(
"/cgi-bin/koha/catalogue/labeledMARCdetail.pl?biblionumber=$biblionumber&found1=1");
} else {
print $cgi->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber&found1=1");
}
}
exit;
}

View file

@ -746,16 +746,20 @@ for (my $i=0;$i<@servers;$i++) {
}
## If there's just one result, redirect to the detail page
if ($total == 1 && $format ne 'rss'
&& $format ne 'opensearchdescription' && $format ne 'atom') {
my $biblionumber=$newresults[0]->{biblionumber};
if (C4::Context->preference('BiblioDefaultView') eq 'isbd') {
if ( $total == 1
&& $format ne 'rss'
&& $format ne 'opensearchdescription'
&& $format ne 'atom'
&& C4::Context->preference('RedirectToSoleResult') )
{
my $biblionumber = $newresults[0]->{biblionumber};
if ( C4::Context->preference('BiblioDefaultView') eq 'isbd' ) {
print $cgi->redirect("/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=$biblionumber");
} elsif (C4::Context->preference('BiblioDefaultView') eq 'marc') {
} elsif ( C4::Context->preference('BiblioDefaultView') eq 'marc' ) {
print $cgi->redirect("/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=$biblionumber");
} else {
print $cgi->redirect("/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber");
}
}
exit;
}
if ($hits) {