]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/parts/record/series.tt2
Make series in record details behave
[working/Evergreen.git] / Open-ILS / src / templates / opac / parts / record / series.tt2
1 [%- 
2     series_tags = ['440', '490', '800', '810', '811', '830', '694']; 
3     loc = ctx.search_ou;
4
5 BLOCK render_series;
6     results = [];
7     FOR tag IN series_tags;
8         FOR node IN ctx.marc_xml.findnodes('//*[@tag="' _ tag _ '"]');
9             all_terms = [];
10             graphics = [];
11             FOR subfield IN node.childNodes;
12                 NEXT UNLESS subfield.nodeName == "subfield";
13                 code = subfield.getAttribute('code');
14                 IF code == '6';
15                    linked_fields = [subfield.textContent()];
16                    target_field = node.getAttribute('tag');
17                    get_linked_880s;
18                 END;
19                 NEXT UNLESS code.match('[a-z]');
20                 # at this point, we actually have a partial term to use.
21                 single_term = subfield.textContent | html;
22                 all_terms.push(subfield.textContent.replace('[#"^$\+\-,\.:;&|\[\]()]', ''));
23                 total_term = all_terms.join(" ").replace('\s+$', '');
24
25                 url = mkurl(ctx.opac_root _ '/results',
26                     { qtype=>'series', query=>total_term }, stop_parms
27                 );
28                 series = series _ '<a href="' _ url _ '">' _ single_term _ '</a> ';
29             END;
30             FOREACH link880 IN graphics;
31                 link = link880.value | html;
32                 series = series _ '<div class="graphic880"' _ link880.dir _ '>' _ link _ '</div>';
33             END;
34             results.push(series);
35
36         END;
37     END; 
38     FOR entry IN results;
39     -%]
40     <li class='rdetail_series_value'>[% entry %]</li>
41     [%- END;
42 END;
43 %]
44
45 [%- series_anchors = PROCESS render_series;
46     IF series_anchors.length > 0; %]
47 <h2 class='rdetail_related_series'>[% l('Search for related items by series') %]</h2>
48 <ul>
49     [% series_anchors %]
50 </ul>
51 [%- END %]