Bugzilla – Attachment 137140 Details for
Bug 29418
Error searching for analytics in detail view
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29418: Make detail rendering use the cleaned-up title for searching
Bug-29418-Make-detail-rendering-use-the-cleaned-up.patch (text/plain), 6.69 KB, created by
David Nind
on 2022-07-04 21:54:04 UTC
(
hide
)
Description:
Bug 29418: Make detail rendering use the cleaned-up title for searching
Filename:
MIME Type:
Creator:
David Nind
Created:
2022-07-04 21:54:04 UTC
Size:
6.69 KB
patch
obsolete
>From 31f0f4532d6003d5c888f6ec6a81b50a14ed259d Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >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=UTF-8 >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 <tomascohen@theke.io> > >Signed-off-by: David Nind <david@davidnind.com> >--- > catalogue/detail.pl | 7 +++++-- > koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl | 3 ++- > koha-tmpl/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 @@ > > <xsl:variable name="show_analytics_link" select="marc:variables/marc:variable[@name='show_analytics_link']" /> > <xsl:if test="$show_analytics_link='1'"> >+ <xsl:variable name="analytics_query" select="marc:variables/marc:variable[@name='analytics_query']" /> > <xsl:element name="span"> > <xsl:attribute name="class">results_summary analytics <xsl:value-of select="$leader7_class"/></xsl:attribute> > <span class="label">Analytics: </span> >@@ -222,7 +223,7 @@ > <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=rcn:<xsl:value-of select="str:encode-uri(marc:controlfield[@tag=001], true())"/>+AND+(bib-level:a+OR+bib-level:b)</xsl:attribute> > </xsl:when> > <xsl:otherwise> >- <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Host-item:(<xsl:value-of select="str:encode-uri(translate(marc:datafield[@tag=245]/marc:subfield[@code='a'], '/', ''), true())"/>)</xsl:attribute> >+ <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Host-item:("<xsl:value-of select="$analytics_query"/>")</xsl:attribute> > </xsl:otherwise> > </xsl:choose> > <xsl:text>Show analytics</xsl:text> >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 @@ > > <xsl:variable name="show_analytics_link" select="marc:variables/marc:variable[@name='show_analytics_link']" /> > <xsl:if test="$show_analytics_link='1'"> >+ <xsl:variable name="analytics_query" select="marc:variables/marc:variable[@name='analytics_query']" /> > <xsl:element name="span"> > <xsl:attribute name="class">results_summary analytics <xsl:value-of select="$leader7_class"/></xsl:attribute> > <span class="label">Analytics: </span> >@@ -257,7 +258,7 @@ > <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=rcn:<xsl:value-of select="str:encode-uri(marc:controlfield[@tag=001], true())"/>+AND+(bib-level:a+OR+bib-level:b)</xsl:attribute> > </xsl:when> > <xsl:otherwise> >- <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Host-item:(<xsl:value-of select="str:encode-uri(translate(marc:datafield[@tag=245]/marc:subfield[@code='a'], '/', ''), true())"/>)</xsl:attribute> >+ <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Host-item:("<xsl:value-of select="$analytics_query"/>")</xsl:attribute> > </xsl:otherwise> > </xsl:choose> > <xsl:text>Show analytics</xsl:text> >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.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29418
:
127325
|
127326
|
134865
|
134866
|
137023
|
137048
|
137135
|
137136
|
137137
|
137138
|
137139
|
137140
|
137142
|
137171
|
137172
|
137173
|
137174