π§ Complete Guide: Replace “Online resources: Click here to access online” with “π Access Online” in Koha 25.11 (Full Code Included)
If you're customizing your Koha OPAC and want a cleaner, modern interface, one common improvement is replacing the default text:
Online resources: Click here to access online
with a simple, user-friendly button:
π Access Online
This guide provides a complete working solution for Koha 25.11, including full XSLT code you can directly use.
π― What You Will Achieve
✔ Remove default repetitive text
✔ Show a clean π Access Online button
✔ Avoid duplication
✔ Keep Koha structure intact
π Where to Apply This
You need to edit:
MARC21slim2OPACResults.xsl
Path:
opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl
π OR (if active):
System Preference → OPACXSLTResultsDisplay
⚠️ IMPORTANT BEFORE YOU START
Check:
π System Preference
OPACXSLTResultsDisplay
If NOT EMPTY → edit code there
If EMPTY → edit file
π§© COMPLETE WORKING CODE (ITEM TYPE + ONLINE BUTTON)
π Paste this in place of your existing 942 + 856 display block
<!-- ================= ITEM TYPE DISPLAY START ================= -->
<xsl:variable name="itype" select="normalize-space(marc:datafield[@tag='942']/marc:subfield[@code='c'])"/>
<span class="itemtype-label" style="font-weight:bold;">
<xsl:choose>
<!-- E-BOOK -->
<xsl:when test="$itype='EBK' or $itype='EBOOK' or $itype='Ebooks' or $itype='E-Book'">
π± E-Book
</xsl:when>
<!-- E-THESIS -->
<xsl:when test="$itype='ETHES' or $itype='E-Thesis'">
ππ» E-Thesis
</xsl:when>
<!-- THESIS -->
<xsl:when test="$itype='THES' or $itype='Thesis'">
π Thesis
</xsl:when>
<!-- ARTICLE -->
<xsl:when test="$itype='AR' or $itype='Articles' or $itype='Article'">
π° Article
</xsl:when>
<!-- MANUSCRIPT -->
<xsl:when test="$itype='MAN' or $itype='Manuscript'">
π Manuscript
</xsl:when>
<!-- BOOK -->
<xsl:when test="$itype='BK' or $itype='Books' or $itype='Book'">
π Book
</xsl:when>
<!-- PERIODICAL -->
<xsl:when test="$itype='SER' or $itype='Periodicals' or $itype='Periodical' or $itype='Serial'">
π Periodical
</xsl:when>
<!-- DEFAULT -->
<xsl:otherwise>
π Other
</xsl:otherwise>
</xsl:choose>
</span>
<!-- ================= ITEM TYPE DISPLAY END ================= -->
<!-- ================= ONLINE ACCESS (REPLACEMENT OF DEFAULT 856) ================= -->
<xsl:if test="marc:datafield[@tag=856]">
<span class="results_summary online_resources">
<xsl:for-each select="marc:datafield[@tag=856]">
<xsl:variable name="url" select="normalize-space(marc:subfield[@code='u'])"/>
<xsl:variable name="linktext" select="normalize-space(marc:subfield[@code='z'])"/>
<xsl:if test="$url != ''">
<a href="{$url}" target="_blank"
style="display:inline-block;
padding:5px 10px;
margin-top:4px;
background:#28a745;
color:#fff;
border-radius:5px;
text-decoration:none;
font-size:12px;">
<xsl:choose>
<!-- SMART LABELS -->
<xsl:when test="contains($url,'.pdf')">
π View PDF
</xsl:when>
<xsl:when test="contains($url,'youtube') or contains($url,'youtu.be')">
π₯ Watch Video
</xsl:when>
<!-- DEFAULT -->
<xsl:when test="$linktext != ''">
π <xsl:value-of select="$linktext"/>
</xsl:when>
<xsl:otherwise>
π Access Online
</xsl:otherwise>
</xsl:choose>
</a>
</xsl:if>
</xsl:for-each>
</span>
</xsl:if>
<!-- ================= END ONLINE ACCESS ================= -->
π§Ή IMPORTANT CLEANUP STEP
π You MUST remove the original default block:
Search and DELETE:
<span class="label">Online resources: </span>
<xsl:text>Click here to access online</xsl:text>
Otherwise duplication will remain.
π APPLY CHANGES
Run:
sudo koha-plack --restart <your-instance>
sudo systemctl restart apache2
Then browser:
Ctrl + Shift + R
✅ FINAL RESULT
❌ Before:
Online resources: Click here to access online
✅ After:
π Access Online
(or dynamic labels like π View PDF / π₯ Watch Video)
π BONUS IMPROVEMENTS (Optional)
You can further enhance:
π¨ Bootstrap badges for item types
π Icons instead of emoji
π Show availability + online button in one row
π Auto-detect DOI links
π Conclusion
By replacing the default Koha 856 display instead of adding a new one, you:
✔ Eliminate duplication
✔ Improve user experience
✔ Modernize OPAC interface
If you want, I can help you:
π Align icons + buttons in one professional layout
π Add colors, hover effects, or tooltips
π Customize for thesis, PDFs, videos, etc.
Just let me know π
No comments:
Post a Comment