]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/opac/parts/record/subjects.tt2
e92644d99b99408fff070c3053af44a691c305b9
[Evergreen.git] / Open-ILS / src / templates / opac / parts / record / subjects.tt2
1 [% 
2     subjects = [
3         {
4             label => l('Subject: '),
5             xpath => '//*[@tag="600" or @tag="610" or @tag="611" or @tag="630" or @tag="650" or @tag="651"]'
6         }, {
7             label => l('Genre: '),
8             xpath => '//*[@tag="655"]|//*[@tag="659"]'
9         }, {
10             label => l('Topic Heading: '),
11             xpath => '//*[@tag="690"]'
12         }, {
13             label => l('Geographic Setting: '),
14             xpath => '//*[@tag="691"]'
15         }, {
16             label => l('Biographical Subject: '),
17             xpath => '//*[@tag="692"]'
18         }, {
19             label => l('Character Attributes: '),
20             xpath => '//*[@tag="693"]'
21         }, {
22             label => l('Setting: '),
23             xpath => '//*[@tag="698"]'
24         }, {
25             label => l('Time Period: '),
26             xpath => '//*[@tag="699"]'
27         }
28     ];
29
30     BLOCK render_subject;
31         xpath = xpath || '//*[starts-with(@tag,"6")]';
32         FOR node IN ctx.marc_xml.findnodes(xpath);
33             all_terms = [];
34             FOR subfield IN node.childNodes;
35                 NEXT UNLESS subfield.nodeName == "subfield";
36                 code = subfield.getAttribute('code');
37                 NEXT UNLESS code.match('[a-z]');
38                 IF code.match('[vxyz]'); " > "; END;
39                 # at this point, we actually have a partial term to use.
40                 single_term = subfield.textContent | html;
41                 all_terms.push(subfield.textContent.replace('[#"^$\+\-,\.:;&|\[\]()]', ''));
42                 total_term = all_terms.join(" ").replace('\s+$', '');
43             %]
44 <a href="[% mkurl(ctx.opac_root _ '/results', {qtype=>'subject', query=>total_term}, stop_parms); %]">[% single_term %]</a>
45             [%- END;
46             IF all_terms.size; "<br/>"; END;
47         END;
48     END 
49 %]
50
51 [%  BLOCK render_all_subjects;
52     FOREACH subj IN subjects;
53         content = PROCESS render_subject(xpath=subj.xpath);
54         IF content.match('\S');
55 %]
56         <table class='rdetail_subject'>
57             <tbody>
58                 <tr>
59                     <td class='rdetail_subject_type'>[% subj.label %]</td>
60                     <td class='rdetail_subject_value' itemprop='keywords'>[% content %]</td>
61                 </tr>
62             </tbody>
63         </table>
64         [%- END; %]
65     [%- END; %]
66 [%- END %]
67
68 [%-  subject_html = PROCESS render_all_subjects;
69     IF subject_html.length > 0;
70 %]
71 <h2 class='rdetail_related_subjects'>[% l('Search for related items by subject') %]</h2>
72 [%- subject_html %]
73 [%- END %]