From 73d7d6602a753e72b77cb84fa53fa5fa398ac1ad Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 1 Jul 2022 11:54:34 -0300 Subject: [PATCH] Bug 29418: Make detail rendering use the cleaned-up title for searching MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch makes both staff and OPAC detail pages generate a valid search link so you can trace related records in the Show analytics link. To test: 1. Pick a bibliographic record (I chose 'Unconditional' from the sample data 2. Add " and ? to the title statement. I changed it to 'Uncond"itional?¿' 3. Add a child record to it 4. Open the detail page for the host record => FAIL: It doesn't show the 'Show analytics' link 5. Repeat 4 for the same record, in the OPAC => FAIL: It doesn't show the 'Show analytics' link 6. Apply this patch 7. Repeat 4 and 5. => SUCCESS: Links are shown! 8. Follow the links => SUCCESS: The links take you to the right resultset! 9. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Victor Grousset/tuxayo --- catalogue/detail.pl | 7 +++++-- .../prog/en/xslt/MARC21slim2intranetDetail.xsl | 3 ++- .../opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl | 3 ++- opac/opac-detail.pl | 7 +++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index f81d1436f4..b765973759 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -138,7 +138,7 @@ if ( $xslfile ) { my $query = ( C4::Context->preference('UseControlNumber') and $record->field('001') ) ? 'rcn:'. $record->field('001')->data . ' AND (bib-level:a OR bib-level:b)' - : "Host-item:($cleaned_title)"; + : "Host-item:(\"$cleaned_title\")"; my ( $err, $result, $count ); eval { ( $err, $result, $count ) = @@ -153,8 +153,11 @@ if ( $xslfile ) { $template->param( analytics_error => 1 ); } + my $show_analytics_link = defined $count && $count > 0 ? 1 : 0; + my $variables = { - show_analytics_link => defined $count && $count > 0 ? 1 : 0 + show_analytics_link => $show_analytics_link, + ( $show_analytics_link ? ( analytics_query => $cleaned_title ) : () ) }; $template->param( diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl index df5ae25179..e0dcfe4fbb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl +++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl @@ -213,6 +213,7 @@ + results_summary analytics Analytics: @@ -222,7 +223,7 @@ /cgi-bin/koha/catalogue/search.pl?q=rcn:+AND+(bib-level:a+OR+bib-level:b) - /cgi-bin/koha/catalogue/search.pl?q=Host-item:() + /cgi-bin/koha/catalogue/search.pl?q=Host-item:("") Show analytics diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl index aa68210291..172a5a0698 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl +++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl @@ -248,6 +248,7 @@ + results_summary analytics Analytics: @@ -257,7 +258,7 @@ /cgi-bin/koha/opac-search.pl?q=rcn:+AND+(bib-level:a+OR+bib-level:b) - /cgi-bin/koha/opac-search.pl?q=Host-item:() + /cgi-bin/koha/opac-search.pl?q=Host-item:("") Show analytics diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index c2225a69a9..dfcb4d07f6 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -195,7 +195,7 @@ if ( $xslfile ) { my $query = ( C4::Context->preference('UseControlNumber') and $record->field('001') ) ? 'rcn:'. $record->field('001')->data . ' AND (bib-level:a OR bib-level:b)' - : "Host-item:($cleaned_title)"; + : "Host-item:(\"$cleaned_title\")"; my ( $err, $result, $count ); eval { ( $err, $result, $count ) = @@ -208,9 +208,12 @@ if ( $xslfile ) { warn "Warning from simple_search_compat: $error"; } + my $show_analytics_link = defined $count && $count > 0 ? 1 : 0; + my $variables = { anonymous_session => ($borrowernumber) ? 0 : 1, - show_analytics_link => defined $count && $count > 0 ? 1 : 0 + show_analytics_link => $show_analytics_link, + ( $show_analytics_link ? ( analytics_query => $cleaned_title ) : () ) }; my @plugin_responses = Koha::Plugins->call( -- 2.39.5