Koha How-To
Make your "OPAC View" link in Koha work with Aspen
Single Libraries Using Koha and 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';
$(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}`); }); } } }); });
Read more by Lucas Gass