From: Jeff Davis Date: Thu, 23 Jul 2020 00:00:30 +0000 (-0700) Subject: LP#1230380: optionally show related online resources in OPAC X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fjeffdavis%2Flp1230380-856-related-resource;p=working%2FEvergreen.git LP#1230380: optionally show related online resources in OPAC Set ctx.show_related_resources to "true" in config.tt2 in order to display 856 tags with '2' as the second indicator in the record summary under a "More information" header. Signed-off-by: Jeff Davis --- diff --git a/Open-ILS/src/templates/opac/parts/config.tt2 b/Open-ILS/src/templates/opac/parts/config.tt2 index 48b4f0fee5..1b955ad472 100644 --- a/Open-ILS/src/templates/opac/parts/config.tt2 +++ b/Open-ILS/src/templates/opac/parts/config.tt2 @@ -275,4 +275,9 @@ ctx.max_cart_size = 500; ############################################################################## ctx.show_reservations_tab = 'false'; +############################################################################## +# Display related resources (856 ind2=2) +############################################################################## +ctx.show_related_resources = 'false'; + %] diff --git a/Open-ILS/src/templates/opac/parts/misc_util.tt2 b/Open-ILS/src/templates/opac/parts/misc_util.tt2 index 609f22d055..6372b0f0d4 100644 --- a/Open-ILS/src/templates/opac/parts/misc_util.tt2 +++ b/Open-ILS/src/templates/opac/parts/misc_util.tt2 @@ -79,6 +79,23 @@ END; END; + MACRO process_856s BLOCK; + label = node.findnodes('./*[@code="y"]'); + notes = node.findnodes('./*[@code="z" or @code="3"]'); + FOR href IN node.findnodes('./*[@code="u"]'); + NEXT UNLESS href; + # it's possible for multiple $u's to exist within 1 856 tag. + # in that case, honor the label/notes data for the first $u, but + # leave any subsequent $u's as unadorned href's. + # use href/link/note keys to be consistent with args.uri's + uri_array.push({ + href => href.textContent, + link => (loop.first AND label) ? label.textContent : href.textContent, + note => (loop.first) ? notes.textContent : '' + }); + END; + END; + BLOCK get_ccvm_icon; ctx.media_prefix _ '/images/format_icons/' _ ccvm.ctype _ '/' _ ccvm.code _ '.png' _ ctx.cache_key; END; @@ -470,20 +487,11 @@ args.online_res = []; FOR node IN xml.findnodes('//*[@tag="856" and @ind1="4" and (@ind2="0" or @ind2="1")]'); IF node.findnodes('./*[@code="9" or @code="w" or @code="n"]'); NEXT; END; # asset.uri's - label = node.findnodes('./*[@code="y"]'); - notes = node.findnodes('./*[@code="z" or @code="3"]'); - FOR href IN node.findnodes('./*[@code="u"]'); - NEXT UNLESS href; - # it's possible for multiple $u's to exist within 1 856 tag. - # in that case, honor the label/notes data for the first $u, but - # leave any subsequent $u's as unadorned href's. - # use href/link/note keys to be consistent with args.uri's - args.online_res.push({ - href => href.textContent, - link => (loop.first AND label) ? label.textContent : href.textContent, - note => (loop.first) ? notes.textContent : '' - }); - END; + process_856s(node=node,uri_array=args.online_res); + END; + args.related_res = []; + FOR node IN xml.findnodes('//*[@tag="856" and @ind1="4" and @ind2="2"]'); + process_856s(node=node,uri_array=args.related_res); END; args.holdings = []; diff --git a/Open-ILS/src/templates/opac/parts/record/summary.tt2 b/Open-ILS/src/templates/opac/parts/record/summary.tt2 index fb6f84a1e8..e749f4c5d1 100644 --- a/Open-ILS/src/templates/opac/parts/record/summary.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/summary.tt2 @@ -239,6 +239,33 @@ IF ebook_api.enabled == 'true'; END; %] [%- END %] +[%- num_related_uris = args.related_res.size; +IF num_related_uris > 0 AND ctx.show_related_resources == 'true'; +-%] +

[% l("More information") %]

+
+ [%- IF num_related_uris > 1 %][% END %] +
+[%- END %]
[%- # Hold/copy summary