TPAC: Prevent numeric subfields in series display
authorDan Scott <dscott@laurentian.ca>
Tue, 8 Jan 2013 22:02:38 +0000 (17:02 -0500)
committerBen Shum <bshum@biblio.org>
Sat, 19 Jan 2013 21:09:25 +0000 (16:09 -0500)
Series fields can theoretically contain linking subfields ($6, $8) and
other numeric subfields that aren't meant to be displayed. So, do not
display them.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/templates/opac/parts/record/series.tt2

index aa96243..6a604af 100644 (file)
@@ -6,16 +6,25 @@
 [% BLOCK render_series;
     results = [];
     FOR tag IN series_tags;
-        FOR node IN ctx.marc_xml.findnodes('//*[@tag="' _ tag _ '"]/*');
-            node_uri = node.textContent.replace('[#"^$\+\-,\.:;&|\[\]()]', '') | uri;
-            node_html = node.textContent | html;
-            IF !loop.first;
-                results.last = result.last _ '<span>&mdash;</span>';
+        FOR node IN ctx.marc_xml.findnodes('//*[@tag="' _ tag _ '"]');
+            series = '';
+            series_link = '';
+            FOR subfield IN node.childNodes;
+                NEXT UNLESS subfield.nodeName == "subfield";
+                code = subfield.getAttribute('code');
+                NEXT UNLESS code.match('[a-z]');
+                node_uri = subfield.textContent.replace('[#"^$\+\-,\.:;&|\[\]()]', '') | uri;
+                node_html = subfield.textContent | html;
+                IF !loop.first;
+                    series = series _ ' ';
+                END;
+                series_link = series_link _ ' ' _ node_uri;
+                series = series _ ('<a href="' _ ctx.opac_root 
+                    _ '/results?qtype=series&amp;query=' _ series_link _ '&amp;loc='
+                    _ loc _ '">' _ node_html _ '</a>'
+                );
             END;
-            results.push('<a href="' _ ctx.opac_root 
-                _ '/results?qtype=series&amp;query=' _ node_uri _ '&amp;loc='
-                _ loc _ '">' _ node_html _ '</a>'
-            );
+            results.push(series);
         END;
     END; 
     FOR entry IN results;