[Koha] Courser reserves on OPAC

Carlos Lopez clopez at dml.vic.edu.au
Tue Mar 31 16:25:28 NZDT 2020


Thanks Eric

Brilliant! Something for me to play with while we're working from home


With kind regards from the Dalton McCaughey Library Team



Carlos Lopez



Dalton McCaughey Library | 29 College Crescent, Parkville, VICTORIA 3052

Ph: 03 9340 8888 ext.1 | library at dml.vic.edu.au<mailto:library at dml.vic.edu.au> | library.dmlibrary.org.au


________________________________
From: Eric Phetteplace <ephetteplace at cca.edu>
Sent: Tuesday, 31 March 2020 1:35 PM
To: Carlos Lopez <clopez at dml.vic.edu.au>
Cc: koha <koha at lists.katipo.co.nz>
Subject: Re: [Koha] Courser reserves on OPAC

Hmm you can ignore the bit about N and N + 1, it seems like jQuery replicates the nth-child behavior in its selector. So my first (JavaScript) example would remove the third column, while the CSS example would remove the fourth, both behaving as you would expect.

Best,

ERIC PHETTEPLACE Systems Librarian (he/him)

ephetteplace at cca.edu<mailto:ephetteplace at cca.edu> | o 510.594.3660

[https://www.cca.edu/sites/default/files/images/cca-logotype-394.png]

5212 Broadway | Oakland, CA | 94618

:(){ :|: & };:


On Mon, Mar 30, 2020 at 7:31 PM Eric Phetteplace <ephetteplace at cca.edu<mailto:ephetteplace at cca.edu>> wrote:
Hi Carlos,

I have not modified the Course Reserves display but yes, this is a perfect example of something that's customizable with JavaScript (OPACUserJS). Something like this hides column N + 1 (in this example the 4th column, Section):

var n = 3
$('#course_reserves_table').find('th:nth-child(' + n + ')') .remove()
$('#course_reserves_table').find('td:nth-child(' + n + ')').remove()

In my opinion, simple hiding something is better suited to CSS, however. So in your OpacUserCSS you could add:

#course_reserves_table th:nth-child(4) { display: none; }
#course_reserves_table td:nth-child(4) { display: none; }

to accomplish the same thing with less code and more reliability. Note that N here works as you would expect because Nth child is indexed starting at one (:nth-child(1) is the same thing as :first-child), while JavaScript follows the convention of indexing things starting at 0.

Reordering columns is a quite bit more complex but could be done with JavaScript. You would want to iterate over children of the thead and tr parent elements and put them in whatever order you want. If you search for "jquery reorder child elements" you can probably find something close. For instance, this Stackoverflow answer shows how to do it with a single list https://stackoverflow.com/questions/3050830/reorder-list-elements-jquery which is analogous to one table row (tr).

Best,

ERIC PHETTEPLACE Systems Librarian (he/him)

ephetteplace at cca.edu<mailto:ephetteplace at cca.edu> | o 510.594.3660

[https://www.cca.edu/sites/default/files/images/cca-logotype-394.png]

5212 Broadway | Oakland, CA | 94618

:(){ :|: & };:


On Mon, Mar 30, 2020 at 3:54 PM Carlos Lopez <clopez at dml.vic.edu.au<mailto:clopez at dml.vic.edu.au>> wrote:
Hi folks

Has anyone had any luck modifying columns on the OPAC Course Reserves display? (suppressing some columns, reordering others)

If so, what was involved? (modifying the template? adding some JS? something else?)


With kind regards from the Dalton McCaughey Library Team



Carlos Lopez



Dalton McCaughey Library | 29 College Crescent, Parkville, VICTORIA 3052

Ph: 03 9340 8888 ext.1 | library at dml.vic.edu.au<mailto:library at dml.vic.edu.au><mailto:library at dml.vic.edu.au<mailto:library at dml.vic.edu.au>> | library.dmlibrary.org.au<http://library.dmlibrary.org.au>

_______________________________________________

Koha mailing list  http://koha-community.org
Koha at lists.katipo.co.nz<mailto:Koha at lists.katipo.co.nz>
Unsubscribe: https://lists.katipo.co.nz/mailman/listinfo/koha

Report this message as spam<https://console.mailguard.com.au/ras/1XQ0QPtrPV/4l91SyMGjsSQUgzRYo4ojl/0.4>



More information about the Koha mailing list