1 <div class="container-fluid my-3">
2 <div class="facet_box_wrapper row">
5 long_facets = CGI.param('long_facet') || [];
6 selected_facets = CGI.param('facet') || [];
8 # sorted list of search facets
11 # we'll clobber the facet. "namespace" later
12 # Provide a default value if unset in config.tt2
13 DEFAULT_DISPLAY_COUNT = facet.default_display_count || 5;
17 # facet display configuration present. Traverse the
18 # configuration lists, find the matching facets from
19 # search facet data, and append them to the sorted
22 FOR display_chunk IN facet.display;
23 FOR display_field IN display_chunk.facet_order;
24 # find the matching facet in the facet data
25 FOR facet IN ctx.search_facets.values;
26 IF facet.cmf.field_class == display_chunk.facet_class
27 AND facet.cmf.name == display_field;
28 sorted_facets.push(facet);
36 # No facet display configuration is present.
37 # show all facets, sorted by name.
39 # collect facet type labels for easier sorting
41 FOR facet IN ctx.search_facets.values;
42 labels.push(facet.cmf.label);
45 # We used to do a sort here, but now that's handled in EGCatLoader.
46 sorted_facets = ctx.search_facets.values;
49 display_count_by_cmf = {};
51 FOR facet IN sorted_facets;
52 fclass = facet.cmf.field_class;
53 fname = facet.cmf.name;
55 long_key = fclass _ fname %]
59 <div class="card-header">
60 <span class="title text-center">[% facet.cmf.label %]</span>
63 <div class="card-body">
65 [% FOR facet_data IN facet.data;
66 display_value = facet_data.value | html;
67 param_string = fclass _ '|' _ fname _ '[' _ facet_data.value _ ']';
70 FOR selected IN selected_facets;
71 IF selected == param_string;
74 new_facets.push(selected);
78 display_count_by_cmf.$fid = display_count_by_cmf.$fid || 0;
80 NEXT UNLESS long_facets.grep(long_key).0 OR
81 display_count_by_cmf.$fid < DEFAULT_DISPLAY_COUNT;
83 # fix syntax highlighting: >
85 display_count_by_cmf.$fid = display_count_by_cmf.$fid + 1;
88 # This facet is already selected by the user.
89 # Link removes the facet from the set of selected facets.
91 <div class="facet_template facet_template_selected">
93 [% IF new_facets.size == 0 %]
95 title="[% l('Show all results, not just those matching this term') %]"
96 href="[% mkurl('', {}, ['facet']) %]" rel="nofollow" vocab="">[% display_value %]</a>
99 title="[% l('Expand to also show results not matching this term') %]"
100 href="[% mkurl('', {facet => new_facets}) %]" rel="nofollow" vocab="">[% display_value %]</a>
103 <div class="count">([% facet_data.count; IF facet_data.count == (ctx.superpage + 1) * ctx.superpage_size; '+'; END %])</div>
107 # This facet is not currently selected. If selected,
108 # append this facet to the list of currently active facets.
110 <div class="facet_template">
113 title="[% l('Limit to results matching this term') %]"
114 href='[% mkurl('', {facet => selected_facets.merge([param_string])}, ['page']) %]' rel="nofollow" vocab="">
118 <div class="count">([% facet_data.count %])</div>
124 <span class="float-right">
125 [% IF long_facets.grep(long_key).0;
127 FOR fct IN long_facets;
132 expand_url = mkurl('', {long_facet => new_long});
133 IF new_long.size == 0;
134 expand_url = mkurl('', {}, ['long_facet']);
137 <a class="button" href="[% expand_url %]#facets"
138 title="[% l('Show Fewer [_1] Entries', facet.cmf.label) %]" rel="nofollow" vocab="">
141 [% ELSIF facet.data.size > DEFAULT_DISPLAY_COUNT %]
143 title="[% l('Show More [_1] Entries', facet.cmf.label) %]"
144 href="[% mkurl('', {long_facet => long_facets.merge([long_key])}) %]#facets" rel="nofollow" vocab="">
151 </div> <!-- box_wrapper -->
152 </div> <!-- facet_box_temp -->
155 </div> <!-- facet_box_wrapper -->