Bugzilla – Attachment 106989 Details for
Bug 15851
Only display "Analytics: Show analytics" when records have linked analytics
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15851: Only display the analytics link when required
Bug-15851-Only-display-the-analytics-link-when-req.patch (text/plain), 5.00 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-07-17 12:50:32 UTC
(
hide
)
Description:
Bug 15851: Only display the analytics link when required
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-07-17 12:50:32 UTC
Size:
5.00 KB
patch
obsolete
>From 263495b92afff7789707703178a141d8bf071695 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 24 Jun 2020 14:50:37 -0300 >Subject: [PATCH] Bug 15851: Only display the analytics link when required > >This patch makes opac-detail.pl query for analytics the same way it >would do with the generated link (i.e. based on UseControlNumber) and >passes a flag to the XSLT so it displays (or not) the 'Analytics' link. > >To test: >1. Apply the first patch >2. Have a known record without analytics >3. Open the record in the OPAC >=> FAIL: It shows the 'Analytics' link >4. Have a record known to have analytics and open in OPAC, on a separate > tab >=> SUCCESS: It shows the 'Analytics' link >5. Apply this patch and restart_all >6. Reload the tabs >=> SUCCESS: It shows the link where it has to, and hides it where it >shouldn't be displayed >7. Sign off :-D > >Sponsored-by: Orex Digital > >Signed-off-by: Hugo Agud <hagud@orex.es> >--- > .../en/xslt/MARC21slim2OPACDetail.xsl | 33 ++++++++++--------- > opac/opac-detail.pl | 18 +++++++++- > 2 files changed, 35 insertions(+), 16 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl >index 884b02a334a..9191908fa35 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl >@@ -353,21 +353,24 @@ > </xsl:choose> > </xsl:variable> > >- <xsl:element name="span"> >- <xsl:attribute name="class">results_summary analytics <xsl:value-of select="$leader7_class"/></xsl:attribute> >- <span class="label">Analytics: </span> >- <a> >- <xsl:choose> >- <xsl:when test="$UseControlNumber = '1' and marc:controlfield[@tag=001]"> >- <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:otherwise> >- </xsl:choose> >- <xsl:text>Show analytics</xsl:text> >- </a> >- </xsl:element> >+ <xsl:variable name="show_analytics_link" select="marc:variables/marc:variable[@name='show_analytics_link']" /> >+ <xsl:if test="$show_analytics_link='1'"> >+ <xsl:element name="span"> >+ <xsl:attribute name="class">results_summary analytics <xsl:value-of select="$leader7_class"/></xsl:attribute> >+ <span class="label">Analytics: </span> >+ <a> >+ <xsl:choose> >+ <xsl:when test="$UseControlNumber = '1' and marc:controlfield[@tag=001]"> >+ <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:otherwise> >+ </xsl:choose> >+ <xsl:text>Show analytics</xsl:text> >+ </a> >+ </xsl:element> >+ </xsl:if> > > <!-- Volumes of sets and traced series --> > <xsl:if test="$materialTypeCode='ST' or substring($controlField008,22,1)='m'"> >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 5c1880fbed2..3f95b45908e 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -61,6 +61,7 @@ use Koha::Virtualshelves; > use Koha::Patrons; > use Koha::Ratings; > use Koha::Reviews; >+use Koha::SearchEngine::Search; > > my $query = CGI->new(); > >@@ -171,8 +172,23 @@ my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef; > > if ( $xslfile ) { > >+ my $searcher = Koha::SearchEngine::Search->new( >+ { index => $Koha::SearchEngine::BIBLIOS_INDEX } >+ ); >+ my $cleaned_title = $biblio->title; >+ $cleaned_title =~ tr|/||; >+ 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"; >+ my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 ); >+ >+ warn "Warning from simple_search_compat: $err" >+ if $err; >+ > my $variables = { >- anonymous_session => ($borrowernumber) ? 0 : 1 >+ anonymous_session => ($borrowernumber) ? 0 : 1, >+ show_analytics_link => $count > 0 ? 1 : 0 > }; > > $template->param( >-- >2.27.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 15851
:
66593
|
106260
|
106261
|
106821
|
106822
|
106988
|
106989
|
106990
|
108049
|
108050
|
108051
|
109267
|
109268
|
109269
|
109459
|
109460
|
109461
|
109462