Last active
September 18, 2019 18:19
-
-
Save phette23/cf5264bc7463024ed408b5895ca379c5 to your computer and use it in GitHub Desktop.
example of displaying 20 most recent bibs from Koha public report
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT b.title, b.author, b.biblionumber | |
FROM biblio b | |
GROUP BY b.datecreated DESC | |
LIMIT 20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.get('https://library.cca.edu/cgi-bin/koha/svc/report?id=340', function(data) { | |
html = '<h1>New Books</h1>' | |
data.forEach(function(book){ | |
// book is an array like [title, author, biblionumber] | |
html += '<a href="https://library.cca.edu/cgi-bin/koha/opac-detail.pl?biblionumber=' + book[2] + '">' + book[0] | |
// author field is sometimes null | |
if (book[1]) html += " by " + book[1] | |
html += '</a><br>' | |
}) | |
$('body').append(html) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Set the report to public, fill in its ID in the URL in the first line of newbooks.js, change the URLs to point to your Koha domain. This just adds a list of links to the bottom of whatever page you run it on:
For a real implementation, you'd want to add some formatting and be more thoughtful about where the
html
in the script is inserted.