TPAC: Display alternate and abbreviated titles
authorDan Scott <dscott@laurentian.ca>
Thu, 25 Oct 2012 18:36:33 +0000 (14:36 -0400)
committerDan Scott <dscott@laurentian.ca>
Thu, 25 Oct 2012 18:42:13 +0000 (14:42 -0400)
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 <dscott@laurentian.ca>
Open-ILS/src/templates/opac/parts/record/summary.tt2
Open-ILS/src/templates/opac/parts/record/titles.tt2 [new file with mode: 0644]

index a5767a1..62432ee 100644 (file)
@@ -164,6 +164,7 @@ IF num_uris > 0;
     [%- END %]
 </ul>
 
+[%- 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 (file)
index 0000000..1d6381b
--- /dev/null
@@ -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; "<br/>"; END;
+    END;
+END 
+%]
+[%  BLOCK render_all_titles;
+    FOREACH title IN titles;
+        content = PROCESS render_titles(xpath=title.xpath);
+        IF content.match('\S');
+-%]
+<tr>
+    <td class='rdetail_content_type'>[% title.label %]</td>
+    <td class='rdetail_content_value' itemprop='keywords'>[% content %]</td>
+</tr>
+        [%- END; %]
+    [%- END; %]
+[%- END %]
+
+[%-  title_html = PROCESS render_all_titles;
+    IF title_html.length > 0;
+%]
+<h2 class='rdetail_titles'>[% l('Other titles') %]</h2>
+<table class='rdetail_title rdetail_content'>
+    <tbody>
+[%- title_html %]
+    </tbody>
+</table>
+[%- END %]