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 %]
57 <div id="facets" class="col-xs-12 col-sm-12 col-md-6 col-lg-3">
59 <div class="card-header">
60 <h4 class="title text-center">[% facet.cmf.label %]</h4>
61 <span class="float-right">
62 [% IF long_facets.grep(long_key).0;
64 FOR fct IN long_facets;
69 expand_url = mkurl('', {long_facet => new_long});
70 IF new_long.size == 0;
71 expand_url = mkurl('', {}, ['long_facet']);
74 <a class="button" href="[% expand_url %]#facets"
75 title="[% l('Show Fewer [_1] Entries', facet.cmf.label) %]" rel="nofollow" vocab="">
78 [% ELSIF facet.data.size > DEFAULT_DISPLAY_COUNT %]
80 title="[% l('Show More [_1] Entries', facet.cmf.label) %]"
81 href="[% mkurl('', {long_facet => long_facets.merge([long_key])}) %]#facets" rel="nofollow" vocab="">
87 <div class="card-body" style="max-height:250px;overflow-x:overlay;">
89 [% FOR facet_data IN facet.data;
90 display_value = facet_data.value | html;
91 param_string = fclass _ '|' _ fname _ '[' _ facet_data.value _ ']';
94 FOR selected IN selected_facets;
95 IF selected == param_string;
98 new_facets.push(selected);
102 display_count_by_cmf.$fid = display_count_by_cmf.$fid || 0;
104 NEXT UNLESS long_facets.grep(long_key).0 OR
105 display_count_by_cmf.$fid < DEFAULT_DISPLAY_COUNT;
107 # fix syntax highlighting: >
109 display_count_by_cmf.$fid = display_count_by_cmf.$fid + 1;
112 # This facet is already selected by the user.
113 # Link removes the facet from the set of selected facets.
115 <div class="facet_template facet_template_selected">
117 [% IF new_facets.size == 0 %]
119 title="[% l('Show all results, not just those matching this term') %]"
120 href="[% mkurl('', {}, ['facet']) %]" rel="nofollow" vocab="">[% display_value %]</a>
123 title="[% l('Expand to also show results not matching this term') %]"
124 href="[% mkurl('', {facet => new_facets}) %]" rel="nofollow" vocab="">[% display_value %]</a>
127 <div class="count">([% facet_data.count; IF facet_data.count == (ctx.superpage + 1) * ctx.superpage_size; '+'; END %])</div>
131 # This facet is not currently selected. If selected,
132 # append this facet to the list of currently active facets.
134 <div class="facet_template">
137 title="[% l('Limit to results matching this term') %]"
138 href='[% mkurl('', {facet => selected_facets.merge([param_string])}, ['page']) %]' rel="nofollow" vocab="">
142 <div class="count">([% facet_data.count %])</div>
149 </div> <!-- box_wrapper -->
150 </div> <!-- facet_box_temp -->
152 </div> <!-- facet_box_wrapper -->