From: Dan Scott Date: Thu, 25 Oct 2012 18:36:33 +0000 (-0400) Subject: TPAC: Display alternate and abbreviated titles X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c25c2a2f9ec25e4e7e75994fbfec2f8bcaa7605a;p=contrib%2FConifer.git TPAC: Display alternate and abbreviated titles In many cases, alternate titles (defined by the MARC 246 field) and abbreviated titles (defined by the 210 field) are valuable data points to display to users. So, display them. Turning this off is a matter of overriding summary.tt2 to remove the titles.tt2 include. Signed-off-by: Dan Scott --- diff --git a/Open-ILS/src/templates/opac/parts/record/summary.tt2 b/Open-ILS/src/templates/opac/parts/record/summary.tt2 index a5767a1f23..62432ee12c 100644 --- a/Open-ILS/src/templates/opac/parts/record/summary.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/summary.tt2 @@ -164,6 +164,7 @@ IF num_uris > 0; [%- END %] +[%- INCLUDE "opac/parts/record/titles.tt2" %] [%- INCLUDE "opac/parts/record/contents.tt2" %] [%- INCLUDE "opac/parts/record/subjects.tt2" %] [%- INCLUDE "opac/parts/record/series.tt2" %] diff --git a/Open-ILS/src/templates/opac/parts/record/titles.tt2 b/Open-ILS/src/templates/opac/parts/record/titles.tt2 new file mode 100644 index 0000000000..1d6381bb2e --- /dev/null +++ b/Open-ILS/src/templates/opac/parts/record/titles.tt2 @@ -0,0 +1,49 @@ +[%- +titles = [ + { + label => l('Abbreviated title: '), + xpath => '//*[@tag="210" and @ind1="1"]' + }, { + label => l('Alternate title: '), + xpath => '//*[@tag="246" and @ind1="1"]' + }, +]; + +BLOCK render_titles; + xpath = xpath || '//*[starts-with(@tag,"2")]'; + FOR node IN ctx.marc_xml.findnodes(xpath); + all_content = []; + FOR subfield IN node.childNodes; + NEXT UNLESS subfield.nodeName == "subfield"; + code = subfield.getAttribute('code'); + NEXT UNLESS code.match('[a-z]'); + all_content.push(subfield.textContent); + total_contents = all_content.join(" ").replace('\s+$', ''); + %] [% total_contents %][%- END; + IF all_content.size; "
"; END; + END; +END +%] +[% BLOCK render_all_titles; + FOREACH title IN titles; + content = PROCESS render_titles(xpath=title.xpath); + IF content.match('\S'); +-%] + + [% title.label %] + [% content %] + + [%- END; %] + [%- END; %] +[%- END %] + +[%- title_html = PROCESS render_all_titles; + IF title_html.length > 0; +%] +

[% l('Other titles') %]

+ + +[%- title_html %] + +
+[%- END %]