lp1271198 Strip browse and facet parameters from links
[working/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             graphics = [];
35             FOR subfield IN node.childNodes;
36                 NEXT UNLESS subfield.nodeName == "subfield";
37                 code = subfield.getAttribute('code');
38                 IF code == '6';
39                    linked_fields = [subfield.textContent()];
40                    target_field = node.getAttribute('tag');
41                    get_linked_880s;
42                 END;
43                 NEXT UNLESS code.match('[a-z]');
44                 IF code.match('[vxyz]'); " > "; END;
45                 # at this point, we actually have a partial term to use.
46                 single_term = subfield.textContent | html;
47                 all_terms.push(subfield.textContent.replace('\-', ' ').replace('[#"^$\+,\.:;&|\[\]()]', ''));
48                 total_term = all_terms.join(" ").replace('\s+$', '');
49             %]
50 <a href="[% mkurl(ctx.opac_root _ '/results', {qtype=>'subject', query=>total_term}, stop_parms.merge(expert_search_parms, general_search_parms, browse_search_parms, facet_search_parms)) %]">[% single_term %]</a>
51             [%- END;
52             IF all_terms.size; "<br/>"; END;
53             FOREACH link880 IN graphics;
54                 '<div class="graphic880"' _ link880.dir _ '>';
55                 link880.value | html;
56                 '</div>';
57             END;
58         END;
59     END 
60 %]
61
62 [%  BLOCK render_all_subjects;
63     FOREACH subj IN subjects;
64         content = PROCESS render_subject(xpath=subj.xpath);
65         IF content.match('\S');
66 %]
67         <table class='rdetail_subject'>
68             <tbody>
69                 <tr>
70                     <td class='rdetail_subject_type'>[% subj.label %]</td>
71                     <td class='rdetail_subject_value' property='keywords'>[% content %]</td>
72                 </tr>
73             </tbody>
74         </table>
75         [%- END; %]
76     [%- END; %]
77 [%- END %]
78
79 [%-  subject_html = PROCESS render_all_subjects;
80     IF subject_html.length > 0;
81 %]
82 <h2 class='rdetail_related_subjects'>[% l('Search for related items by subject') %]</h2>
83 [%- subject_html %]
84 [%- END %]