Make your "OPAC View" link in Koha work with Aspen

Make your "OPAC View" link in Koha work with Aspen

This is a little trick for libraries using Aspen as a discovery layer and Koha as a backend. In the Koha staff client you may be familiar with a button on the record detail page that says: “OPAC view: Open in a new window”. This whisks you away to the corresponding record in the Koha OPAC. If you are now using Aspen that would be a bit confusing for staff!

There is an similar link to the OPAC on the serial subscription page and we'll be fixing that one up too!

Luckily, we can add some very simple jQuery to the Koha system preference IntranetUserJS that can solve this problem and redirect you to the correct Aspen page instead! First we must define our Aspen catalog's base URL:

let baseURL = 'https://{YOURURL}.aspendiscovery.org';
This is the only component of the jQuery that will be unique to you. Replace 'https://{YOURURL}.aspendiscovery.org' with your own Aspen base URL!

After that single line has been added to IntranetUserJS we can add the rest of jQuery underneath it. None of the following jQuery needs to be edited, just cut and paste!.

 /* change OPAC link on record detail page*/
 if ( $('#catalog_detail').length ) {
 let bib = $('input[name="bib"]').val();
 $('.results_summary > a:contains("Open in new window")').attr('href' , `${baseURL}/Record/${bib}`); 
 }

 /* change OPAC link on subscription detail page*/
 if ( $('#ser_subscription-detail').length ) {
 let bibtext = $('#subscription_info ol > li > i').text();
 let re = /\(([^\)]+)\)/;
 let bib = bibtext.match(re);
 $('#view-subscription-in-opac').attr('href' , `${baseURL}/Record/${bib[1]}`);
 }

/* change OPAC link in search results*/
if ($('#catalog_results').length) {
 $('#searchresults table tbody tr').each(function() {
 let bib = $(this).find('input[name="biblionumber"]').val();
 $(this).find('.view-in-opac > a').attr('href', `${baseURL}/Record/${bib}`);
 });
}

Now the the ‘Open in a new window’ button should now take you to the proper record in Aspen instead of Koha!

Library Systems with Multiple Catalogs

To have your Koha OPAC View link point to different catalogs depending on the Home Library of the staff user in Koha, use this bit of code.

First, look up the system preference OPACBaseURL and make sure the URL in this field is your Koha OPAC URL. This typically looks something like: https://{YOURLIBRARY}.bywatersolutions.com

Next, search for the system preference IntranetUserJS and edit.

In the text box, paste in the code below. Edit the code to replace each placeholder of {MainAspenURL} with the primary Aspen URL for your consortium. If you don't have a single catalog for the entire consortium, delete the line in the code in the first section below that begins with "N:" and ends with "</a>'," and proceed to the next step.

Replace the list of branch codes ({branchcode1}, {branchcode2}, etc.) with your branch codes in Koha. These codes can be found from Koha administration > Libraries. Replace {AspenURL} with that library's unique Aspen URL. Example: WEST: 'west.aspendiscovery.org'; EAST: 'east.aspendiscovery.org'; MAIN: 'central.aspendiscovery.org';

Info
$(document).ready(function () {
 /* create key value pairs like this, branchcode: 'baseurl' */
 const library_aspen_url = {
 N: '<a target="_blank" data-stringify-link="https://{MainAspenURL}" delay="150" data-sk="tooltip_parent" href="https://{MainAspenURL}/" rel="noopener noreferrer">https://{MainAspenURL}</a>',
 {branchcode1}: '{AspenURL}',
 {branchcode2}: '{AspenURL}',
 {branchcode3}: '{AspenURL}',
 
 };
 let librarybranch = $('.logged-in-branch-code:first').text();
 Object.keys(library_aspen_url).forEach(function (item) {
 if ( item === librarybranch ) {
 /* change OPAC link on record detail page*/
 if ( $('#catalog_detail').length ) {
 let bib = $('input[name="bib"]').val();
 $('.results_summary > a:contains("Open in new window")').attr('href' , `${library_aspen_url[item]}/Record/${bib}`); 
 }

 /* change OPAC link on subscription detail page*/
 if ( $('#ser_subscription-detail').length ) {
 let bibtext = $('#subscription_info ol > li > i').text();
 let re = /\(([^\)]+)\)/;
 let bib = bibtext.match(re);
 $('#view-subscription-in-opac').attr('href' , `${library_aspen_url[item]}/Record/${bib[1]}`);
 }

/* change OPAC link in search results*/
if ($('#catalog_results').length) {
 $('#searchresults table tbody tr').each(function() {
 let bib = $(this).find('input[name="biblionumber"]').val();
 $(this).find('.view-in-opac > a').attr('href', `${library_aspen_url[item]}/Record/${bib}`);
 });
}
 }
 });
});

    • Related Articles

    • Customizing the OPAC

      There are many ways to customize the OPAC in Koha. This includes custom colors, adding coverflows, customizing search, and adding custom news and content. Using the Galadriel Plugin to Customize the OPAC The Galadriel plugin is a great tool to ...
    • Password Reset via Email in Aspen Discovery and Koha

      In order to enable the password reset prior to login you will want to enable the ability within Aspen under Primary Configuration. Open the library system you want this ability for and scroll down to ILS/Account integration. Within User Profile you ...
    • Aspen/Koha Glossary

      Aspen Koha Description Materials request Purchase suggestion Allows patrons to request that the library purchase a title Freeze/unfreeze Suspend/unsuspend Temporary pause on a hold Patron types Patron categories Broad groupings of patrons (including ...
    • Integrating Quipu with Aspen & Koha

      Aspen supports Quipu eCARD (self-registration) and eRENEW (patron account renewal). First, decide whether your library would like to have Quipu's form display in Aspen or embed it on your website. Aspen setup If you want to keep the form on your ...
    • Customizing MARC Frameworks in Koha

      Changing your library’s frameworks to fit cataloging needs is simple! Here are the steps: Overview MARC Frameworks can be found in the Administration Module under Catalog. To view a specific framework’s subfields, click the action button and choose ...