Bug 26890 raises the point that there's no biblionumber on the detail page that is easily Javascript accessible. We really should be publishing the biblionumber in a feature-independent way, so that different features can leverage the same biblionumber. Here's my ideas so far: 1. data-biblionumber attribute in the body element 2. A RDFa schema.org identifier put in a child of the div.record element 3. Use Template::Toolkit to create a Javascript object that contains the biblionumber as a property 4. HTML element like "<span class="label">Catalogue ID</span>: <span id="biblionumber">1234</span>" I'm actually kind of inclined towards #4, since I have occasionally had people ask for the biblionumber to be published on the HTML to make it easier to see and reference... (although more so for the Staff Interface than the OPAC admittedly)
Ok maybe not body as that would involve updating bodytag.inc, which is too far reaching. div#catalogue_detail_biblio would work though as follows: <div id="catalogue_detail_biblio" class="maincontent" data-biblionumber="29"> Looks like the schema.org is partially in the XSLT and partially in opac-detail.tt so that's... no.
(In reply to David Cook from comment #1) > <div id="catalogue_detail_biblio" class="maincontent" data-biblionumber="29"> > Then you can grab the biblionumber as easily as doing the following: document.querySelector("div#catalogue_detail_biblio").dataset.biblionumber; Or jquery: $("div#catalogue_detail_biblio").attr("data-biblionumber"); $("div#catalogue_detail_biblio").data("biblionumber");
Created attachment 113648 [details] [review] Bug 27029: Add data-biblionumber attribute to OPAC detail page This patch adds a data-biblionumber attribute to the div#catalogue_detail_biblio elements on opac-detail.pl, so that Javascript running on the page can easily fetch and use the record's biblionumber.
Note that this would be useful for Koha plugins or any OPACUserJS which wants to add functionality onto the OPAC detail page.
Adding myself as Assignee, but still curious what Owen Leonard thinks.
Thx for the quick uptake on my idea/wish I'll look into it, I'll try to make it today
I tested this fix, what is the process to sign it off?
(In reply to Mark Hofstetter from comment #7) > I tested this fix, what is the process to sign it off? Thanks, Mark. You should be able to find everything you need here: https://wiki.koha-community.org/wiki/Git_bz_configuration#Signing_off Since you've already marked it as Signed Off on Bugzilla, it basically boils down to adding a "Signed-off-by: Mark Hofstetter <koha@trust-box.at>" to the bottom of my patch and re-uploading to replace my original patch.
Created attachment 113705 [details] [review] Bug 27029: Add data-biblionumber attribute to OPAC detail page This patch adds a data-biblionumber attribute to the div#catalogue_detail_biblio elements on opac-detail.pl, so that Javascript running on the page can easily fetch and use the record's biblionumber. Signed-off-by: Mark Hofstetter <mark@hofstetter.at>, <koha@trust-box.at>
Perfect, Mark! If you go to https://dashboard.koha-community.org/, you'll also see that your name now appears in the list of sign offs as well.
until the patch is in core you may use // "if" statment may/has to be removed when // https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27029 // is in koha var biblionumber = $("div#catalogue_detail_biblio").data("biblionumber"); if (!biblionumber) { var x = document.getElementsByClassName("unapi-id")[0] .getAttribute("title"); biblionumber = x.split(':')[2]; } see https://github.com/HKS3/koha-plugin-subordinate-items/
Created attachment 115675 [details] [review] Bug 27029: Add data-biblionumber attribute to OPAC detail page This patch adds a data-biblionumber attribute to the div#catalogue_detail_biblio elements on opac-detail.pl, so that Javascript running on the page can easily fetch and use the record's biblionumber. Signed-off-by: Mark Hofstetter <mark@hofstetter.at>, <koha@trust-box.at> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 115676 [details] [review] Bug 27029: (QA follow-up) Adding html filter Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 115862 [details] [review] Bug 27029: Add a selenium regression test
Pushed to master for 21.05, thanks to everybody involved!
Nice small enhancement, I choose to backport. Pushed to 20.11.x for 20.11.03
Agreed, this seems small and handy. Pushed t0 20.05.x for 20.05.09
Not backported to oldoldstable (19.11.x). Feel free to ask if it's needed.