Koha How-To

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://aspen-model.bywatersolutions.com';

This is the only component of the jQuery that will be unique to you. Replace 'https://aspen-model.bywatersol...' 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!

Read more by Lucas Gass

Tags Aspen Discovery