Skip to content

Instantly share code, notes, and snippets.

@phette23
Last active September 18, 2019 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phette23/cf5264bc7463024ed408b5895ca379c5 to your computer and use it in GitHub Desktop.
Save phette23/cf5264bc7463024ed408b5895ca379c5 to your computer and use it in GitHub Desktop.
example of displaying 20 most recent bibs from Koha public report
SELECT b.title, b.author, b.biblionumber
FROM biblio b
GROUP BY b.datecreated DESC
LIMIT 20
$.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)
})
@phette23
Copy link
Author

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:

Screen Shot 2019-09-18 at 11 11 42

For a real implementation, you'd want to add some formatting and be more thoughtful about where the html in the script is inserted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment