1 <div class="facet_box_wrapper">
4 long_facets = CGI.param('long_facet') || [];
5 selected_facets = CGI.param('facet') || [];
7 # sorted list of search facets
10 # we'll clobber the facet. "namespace" later
11 # Provide a default value if unset in config.tt2
12 DEFAULT_DISPLAY_COUNT = facet.default_display_count || 5;
16 # facet display configuration present. Traverse the
17 # configuration lists, find the matching facets from
18 # search facet data, and append them to the sorted
21 FOR display_chunk IN facet.display;
22 FOR display_field IN display_chunk.facet_order;
23 # find the matching facet in the facet data
24 FOR facet IN ctx.search_facets.values;
25 IF facet.cmf.field_class == display_chunk.facet_class
26 AND facet.cmf.name == display_field;
27 sorted_facets.push(facet);
35 # No facet display configuration is present.
36 # show all facets, sorted by name.
38 # collect facet type labels for easier sorting
40 FOR facet IN ctx.search_facets.values;
41 labels.push(facet.cmf.label);
44 # We used to do a sort here, but now that's handled in EGCatLoader.
45 sorted_facets = ctx.search_facets.values;
48 display_count_by_cmf = {};
50 FOR facet IN sorted_facets;
51 fclass = facet.cmf.field_class;
52 fname = facet.cmf.name;
54 long_key = fclass _ fname %]
56 <div class="facet_box_temp">
58 [% IF long_facets.grep(long_key).0;
60 FOR fct IN long_facets;
65 expand_url = mkurl('', {long_facet => new_long});
66 IF new_long.size == 0;
67 expand_url = mkurl('', {}, ['long_facet']);
70 <a class="button" href="[% expand_url %]"
71 title="[% l('Show Fewer [_1] Entries', facet.cmf.label) %]" rel="nofollow" vocab="">
74 [% ELSIF facet.data.size > DEFAULT_DISPLAY_COUNT %]
76 title="[% l('Show More [_1] Entries', facet.cmf.label) %]"
77 href="[% mkurl('', {long_facet => long_facets.merge([long_key])}) %]" rel="nofollow" vocab="">
81 <h4 class="title">[% facet.cmf.label %]</h4>
83 <div class="box_wrapper">
85 [% FOR facet_data IN facet.data;
86 display_value = facet_data.value | html;
87 param_string = fclass _ '|' _ fname _ '[' _ facet_data.value _ ']';
90 FOR selected IN selected_facets;
91 IF selected == param_string;
94 new_facets.push(selected);
98 display_count_by_cmf.$fid = display_count_by_cmf.$fid || 0;
100 NEXT UNLESS long_facets.grep(long_key).0 OR
101 display_count_by_cmf.$fid < DEFAULT_DISPLAY_COUNT;
103 # fix syntax highlighting: >
105 display_count_by_cmf.$fid = display_count_by_cmf.$fid + 1;
108 # This facet is already selected by the user.
109 # Link removes the facet from the set of selected facets.
111 <div class="facet_template facet_template_selected">
113 [% IF new_facets.size == 0 %]
115 title="[% l('Show all results, not just those matching this term') %]"
116 href="[% mkurl('', {}, ['facet']) %]" rel="nofollow" vocab="">[% display_value %]</a>
119 title="[% l('Expand to also show results not matching this term') %]"
120 href="[% mkurl('', {facet => new_facets}) %]" rel="nofollow" vocab="">[% display_value %]</a>
123 <div class="count">([% facet_data.count %])</div>
127 # This facet is not currently selected. If selected,
128 # append this facet to the list of currently active facets.
130 <div class="facet_template">
133 title="[% l('Limit to results matching this term') %]"
134 href='[% mkurl('', {facet => selected_facets.merge([param_string])}, ['page']) %]' rel="nofollow" vocab="">
138 <div class="count">([% facet_data.count %])</div>
143 </div> <!-- box_wrapper -->
144 </div> <!-- facet_box_temp -->
146 </div> <!-- facet_box_wrapper -->