]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/templates/default/opac/parts/record/subjects.tt2
More config docs for SFX resolver TTOPAC bits
[working/Evergreen.git] / Open-ILS / web / templates / default / opac / parts / record / subjects.tt2
1 [% 
2     subjects = [
3         {
4             label => l('Genre: '),
5             xpath => '//*[@tag="655"]|//*[@tag="659"]'
6         }, {
7             label => l('Topic Heading: '),
8             xpath => '//*[@tag="690"]'
9         }, {
10             label => l('Geographic Setting: '),
11             xpath => '//*[@tag="691"]'
12         }, {
13             label => l('Biographical Subject: '),
14             xpath => '//*[@tag="692"]'
15         }, {
16             label => l('Character Attributes: '),
17             xpath => '//*[@tag="693"]'
18         }, {
19             label => l('Setting: '),
20             xpath => '//*[@tag="698"]'
21         }, {
22             label => l('Time Period: '),
23             xpath => '//*[@tag="699"]'
24         }
25     ];
26
27     BLOCK render_subject;
28         loc = CGI.param('loc') | uri;
29         xpath = xpath || '//*[starts-with(@tag,"6")]';
30         FOR node IN ctx.marc_xml.findnodes(xpath);
31             all_terms = [];
32             FOR subfield IN node.childNodes;
33                 NEXT UNLESS subfield.nodeName == "subfield";
34                 code = subfield.getAttribute('code');
35                 NEXT UNLESS code.match('[a-z]');
36                 IF code.match('[vxyz]'); " — "; END;
37                 # at this point, we actually have a partial term to use.
38                 single_term = subfield.textContent | html;
39                 all_terms.push(subfield.textContent);
40                 total_term = all_terms.join(" ").replace('\s+$', '') | uri;
41                 '<a href="' _ ctx.opac_root _ '/results?qtype=subject&amp;query=' _ total_term _ '&amp;loc=' _ loc _ '">' _ single_term _ '</a>';
42             END;
43             IF all_terms.size; "<br/>"; END;
44         END;
45     END 
46 %]
47
48 <div id='rdetail_subject_div'>
49     <table cellpadding="0" cellspacing="0" border="0">
50     [%  any_subjects = 0;
51         FOREACH subj IN subjects;
52             content = PROCESS render_subject(xpath=subj.xpath);
53             IF content.match('\S');
54                 any_subjects = 1; %]
55             <tr>
56                 <td width="1" style="padding:5px 7px 0px 0px;" valign="top">
57                     <strong>[% subj.label %]</strong>
58                 </td>
59                 <td style="padding-top:5px;"><div>[% content %] </div></td>
60             </tr>
61             [% END; %]
62         [% END; %]
63     [% IF any_subjects == 0 %]
64         <tr><td><i>[% l('No Subjects') %]</i></td></tr>
65     [% END; %]
66     </table>
67 </div>