Bug 36750: (35138 follow-up) Use same display code for OPAC
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / includes / opac-facets.inc
1 [% USE raw %]
2 [% USE AuthorisedValues %]
3 [% USE Languages %]
4 [% PROCESS 'i18n.inc' %]
5 [% USE AdditionalContents %]
6 [% SET OPACResultsSidebar = AdditionalContents.get( location => "OPACResultsSidebar", lang => lang, library => logged_in_user.branchcode || default_branch ) %]
7 [% IF ( opacfacets && facets_loop && total ) %]
8     <div id="search-facets">
9         <h2><a href="#" class="menu-collapse-toggle">Refine your search</a></h2>
10         <ul class="menu-collapse">
11             [% IF Koha.Preference("SavedSearchFilters") && search_filters.size > 0 %]
12             <li id="search-filters">
13             <h3 id="filter_facets">Custom search filters</h3>
14             <ul>
15                 [% SET base_url = "/cgi-bin/koha/opac-search.pl?" _ query_cgi _ limit_cgi %]
16                 [% FOREACH search_filter IN search_filters %]
17                     [% SET search_filter_id = search_filter.id | uri %]
18                 <li>
19                     [% IF active_filters.${search_filter.id} %]
20                         <span class="filter_label">[% search_filter.name | html %]<a href="[% base_url _ '&nolimit=search_filter:' _ search_filter_id | $raw %]">[x]</a></span>
21                     [% ELSE %]
22                         <span class="filter_label"><a href="[% base_url _ '&limit=search_filter:' _ search_filter_id | $raw %]">[% search_filter.name | html %]</a></span>
23                     [% END %]
24                 </li>
25                 [% END %]
26             </ul>
27             </li>
28             [% END %]
29             <li id="availability_facet"><h3 id="facet-availability">Availability</h3>
30                 <ul>
31                     <li>
32                         [% IF ( available ) %]
33                             <strong>Showing only records with available items</strong></li><li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi_not_availablity | $raw %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |uri %][% END %]">Show all records</a>
34                         [% ELSE %]
35                             <a href="/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |uri %][% END %]&amp;limit=available">Limit to records with available items</a>
36                         [% END %]
37                     </li>
38                 </ul>
39                 [% IF ( related ) %] <li>(related searches: [% FOREACH relate IN related %][% relate.related_search | html %][% END %])</li>[% END %]
40             </li>
41
42             [% SET more_less_labels = {} %]
43             [% more_less_labels.Authors         = { more = t("Show more authors"),           less = t("Show fewer authors") }           %]
44             [% more_less_labels.Titles          = { more = t("Show more titles"),            less = t("Show fewer titles") }            %]
45             [% more_less_labels.Topics          = { more = t("Show more topics"),            less = t("Show fewer topics") }            %]
46             [% more_less_labels.Places          = { more = t("Show more places"),            less = t("Show fewer places") }            %]
47             [% more_less_labels.Series          = { more = t("Show more series"),            less = t("Show fewer series") }            %]
48             [% more_less_labels.ItemTypes       = { more = t("Show more item types"),        less = t("Show fewer item types") }        %]
49             [% more_less_labels.CollectionCodes = { more = t("Show more collections"),       less = t("Show fewer collections") }       %]
50             [% more_less_labels.Language        = { more = t("Show more languages"),         less = t("Show fewer languages") }         %]
51             [% more_less_labels.HomeLibrary     = { more = t("Show more home libraries"),    less = t("Show fewer home libraries") }    %]
52             [% more_less_labels.HoldingLibrary  = { more = t("Show more holding libraries"), less = t("Show fewer holding libraries") } %]
53             [% more_less_labels.Location        = { more = t("Show more locations"),         less = t("Show fewer locations") }         %]
54             [% FOREACH facets_loo IN facets_loop %]
55                 [% IF facets_loo.facets.size > 0 %]
56                     <li id="[% facets_loo.type_id | html %]">
57                             [% SWITCH facets_loo.label %]
58                             [% CASE 'Authors' %]
59                                 <h3 id="facet-authors">Authors</h3>
60                             [% CASE 'Titles' %]
61                                 <h3 id="facet-titles">Titles</h3>
62                             [% CASE 'Topics' %]
63                                 <h3 id="facet-topics">Topics</h3>
64                             [% CASE 'Places' %]
65                                 <h3 id="facet-places">Places</h3>
66                             [% CASE 'Series' %]
67                                 <h3 id="facet-series">Series</h3>
68                             [% CASE 'ItemTypes' %]
69                                 <h3 id="facet-itemtypes">Item types</h3>
70                             [% CASE 'homelibrary' %]
71                                 <h3 id="facet-home-libraries">Home libraries</h3>
72                             [% CASE 'HoldingLibrary' %]
73                                 <h3 id="facet-holding-libraries">Holding libraries</h3>
74                             [% CASE 'Location' %]
75                                 <h3 id="facet-locations">Locations</h3>
76                             [% CASE 'CollectionCodes' %]
77                                 <h3 id="facet-collections">Collections</h3>
78                             [% CASE 'Languages' %]
79                                 <h3 id="facet-languages">Languages</h3>
80                             [% CASE %]
81                                 <h3 id="facet-[% facets_loo.type_link_value | html %]">[% facets_loo.label | html %]</h3>
82                             [% END %]
83                         <ul>
84                             [% SET url = "/cgi-bin/koha/opac-search.pl?" _ query_cgi _ limit_cgi %]
85                             [% IF ( sort_by ) %]
86                               [% url = BLOCK %][% url | $raw %][% "&amp;sort_by=" _ sort_by | url %][% END %]
87                             [% END %]
88                             [% IF ( results_per_page ) %]
89                               [% url = BLOCK %][% url | $raw %][% "&amp;count=" _ results_per_page | url %][% END %]
90                             [% END %]
91                             [% FOREACH facet IN facets_loo.facets %]
92                             [% IF facets_loo.type_label_CollectionCodes %][% SET facet.facet_label_value = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => facet.facet_label_value, opac =>1 ) || facet.facet_label_value %][% END %]
93                             [% IF facets_loo.type_label_Language %][% SET facet.facet_label_value = Languages.GetByISOCode(lang,facet.facet_label_value) || facet.facet_label_value %][% END %]
94                             [% IF loop.count > 5 && !facet.active %]
95                                 <li class="collapsible-facet" style="display:none">
96                             [% ELSE %]
97                                 <li>
98                             [% END %]
99                                   [% IF facet.active %]
100                                     [% local_url = BLOCK %][% url | $raw %][% "&nolimit=" _  facet.type_link_value _ ":" _ facet.facet_link_value | url %][% END %]
101                                     <span class="facet-label">[% facet.facet_label_value | html %]</span>
102                                     [% IF ( displayFacetCount ) %]
103                                       <span class="facet-count-selected">([% facet.facet_count | html %])</span>
104                                     [% END %]
105                                     [<a href="[% local_url | $raw %]" title="Remove facet [% facet.facet_label_value | html %]">x</a>]
106                                   [% ELSE %]
107                                     [% local_url = BLOCK %][% url | $raw %][% "&limit=" _  facet.type_link_value _ ":" _ facet.facet_link_value | url %][% END %]
108                                     <span class="facet-label"><a href="[% local_url | $raw %]" title="[% facet.facet_title_value | html %]">[% facet.facet_label_value | html %]</a></span>
109                                     [% IF ( displayFacetCount ) %]
110                                       <span class="facet-count"> ([% facet.facet_count | html %])</span>
111                                     [% END %]
112                                   [% END %]
113                                 </li>
114                             [% END %]
115                             [% IF facets_loo.facets.size > 5 %]
116                                 <li class="moretoggle">
117                                     [% FOR label IN more_less_labels.keys %]
118                                         [% IF facets_loo.item('type_label_' _ label) %]
119                                             <a href="#" aria-label="[% more_less_labels.item(label).more || t('Show more') | html | trim %]"><strong>Show more</strong></a>
120                                         [% END %]
121                                     [% END %]
122                                 </li>
123                                 <li class="moretoggle" style="display:none">
124                                     [% FOR label IN more_less_labels.keys %]
125                                         [% IF facets_loo.item('type_label_' _ label) %]
126                                             <a href="#" aria-label="[% more_less_labels.item(label).less || t('Show less') | html | trim %]"><strong>Show less</strong></a>
127                                         [% END %]
128                                     [% END %]
129                                 </li>
130                             [% END %]
131                         </ul>
132                     </li>
133                 [% END # / IF facets_loo.facets.size > 0 %]
134             [% END # / FOREACH facets_loo  %]
135         </ul>
136     </div>  <!-- / #search-facets -->
137
138     [% IF ( OPACResultsSidebar ) %]
139         <div id="opacresultssidebar">
140             [% PROCESS koha_news_block news => OPACResultsSidebar %]
141         </div>
142     [% END %]
143 [% END # / IF opacfacets && facets_loop %]