Tuesday, April 21, 2026

Complete Guide: Replace “Online resources: Click here to access online” with “🌐 Access Online” in Koha 25.11 (Full Code Included)

 

πŸ”§ 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

Complete Guide: Replace “Online resources: Click here to access online” with “🌐 Access Online” in Koha 25.11 (Full Code Included)

  πŸ”§ Complete Guide: Replace “Online resources: Click here to access online” with “🌐 Access Online” in Koha 25.11 (Full Code Included) If y...