Koha/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc
Nick Clemens 59918a3c21 Bug 18213: Add language facets to Elasticsearch
This patch add language as a facet to ES results - it adds
a new template plugin for languages to get the appropriate
description given an iso 639-2 code

To test:
1 - Make sure you have records with differing languages (in the MARC21 008
        field characters 35-37 or UNIMARC 101a)
2 - Apply patch
3 - Reload Elasticsearch settings:
http://localhost:8081/cgi-bin/koha/admin/searchengine/elasticsearch/mappings.pl?op=reset&i_know_what_i_am_doing=1
4 - Reindex your records
5 - Search for a phrase that will return results in several languages
6 - Verify you see factes correctly labelled for 'Language'
7 - Verify the facets work
8 - Verify both opac and staff results
9 - prove t/db_dependent/Languages.t

Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr>
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2019-03-28 15:57:32 +00:00

76 lines
5.4 KiB
HTML

[% USE raw %]
[% USE AuthorisedValues %]
[% USE Languages %]
[% IF ( opacfacets && facets_loop && total ) %]
<div id="search-facets">
<h4><a href="#" class="menu-collapse-toggle">Refine your search</a></h4>
<ul class="menu-collapse">
<li id="availability_facet"><h5 id="facet-availability">Availability</h5>
<ul>
<li>
[% IF ( available ) %]
<strong>Showing only available items</strong></li><li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi_not_availablity | uri %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by |uri %][% END %]">Show all items</a>
[% ELSE %]
<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 currently available items.</a>
[% END %]
</li>
</ul>
[% IF ( related ) %] <li>(related searches: [% FOREACH relate IN related %][% relate.related_search | html %][% END %])</li>[% END %]
</li>
[% FOREACH facets_loo IN facets_loop %]
[% IF facets_loo.facets.size > 0 %]
<li id="[% facets_loo.type_id | html %]">
[% IF facets_loo.type_label_Authors %]<h5 id="facet-authors">Authors</h5>[% END %]
[% IF facets_loo.type_label_Titles %]<h5 id="facet-titles">Titles</h5>[% END %]
[% IF facets_loo.type_label_Topics %]<h5 id="facet-topics">Topics</h5>[% END %]
[% IF facets_loo.type_label_Places %]<h5 id="facet-places">Places</h5>[% END %]
[% IF facets_loo.type_label_Series %]<h5 id="facet-series">Series</h5>[% END %]
[% IF facets_loo.type_label_ItemTypes %]<h5 id="facet-itemtypes">Item types</h5>[% END %]
[% IF facets_loo.type_label_CollectionCodes %]<h5 id="facet-collections">Collections</h5>[% END %]
[% IF facets_loo.type_label_Language %]<h5 id="facet-languages">Languages</h5>[% END %]
[% UNLESS singleBranchMode %]
[% IF ( facets_loo.type_label_HomeLibrary ) %]<h5 id="facet-home-libraries">Home libraries</h5>[% END %]
[% IF ( facets_loo.type_label_HoldingLibrary ) %]<h5 id="facet-holding-libraries">Holding libraries</h5>[% END %]
[% END %]
[% IF facets_loo.type_label_Location %]<h5 id="facet-locations">Locations</h5>[% END %]
<ul>
[% SET url = "/cgi-bin/koha/opac-search.pl?" _ query_cgi _ limit_cgi %]
[% IF ( sort_by ) %]
[% url = BLOCK %][% url | $raw %][% "&amp;sort_by=" _ sort_by | url %][% END %]
[% END %]
[% FOREACH facet IN facets_loo.facets %]
[% IF facets_loo.type_label_CollectionCodes %][% SET facet.facet_label_value = AuthorisedValues.GetByCode('CCODE',facet.facet_label_value,1) || facet.facet_label_value %][% END %]
[% IF facets_loo.type_label_Language %][% SET facet.facet_label_value = Languages.GetByISOCode(lang,facet.facet_label_value) || facet.facet_label_value %][% END %]
<li>
[% IF facet.active %]
[% local_url = BLOCK %][% url | $raw %][% "&nolimit=" _ facet.type_link_value _ ":" _ facet.facet_link_value | url %][% END %]
<span class="facet-label">[% facet.facet_label_value | html %]</span>
[<a href="[% local_url | $raw %]" title="Remove facet [% facet.facet_link_value | html %]">x</a>]
[% ELSE %]
[% local_url = BLOCK %][% url | $raw %][% "&limit=" _ facet.type_link_value _ ":" _ facet.facet_link_value | url %][% END %]
<span class="facet-label"><a href="[% local_url | $raw %]" title="[% facet.facet_title_value | html %]">[% facet.facet_label_value | html %]</a></span>
[% IF ( displayFacetCount ) %]
<span class="facet-count"> ([% facet.facet_count | html %])</span>
[% END %]
[% END %]
</li>
[% END %]
[% IF ( facets_loo.expandable ) %]
<li class="showmore">
<a href="[% url | $raw %][% IF offset %]&amp;offset=[% offset | uri %][% END %]&amp;expand=[% facets_loo.expand | uri %]#[% facets_loo.type_id | uri %]">Show more</a>
</li>
[% END %]
</ul>
</li>
[% END # / IF facets_loo.facets.size > 0 %]
[% END # / FOREACH facets_loo %]
</ul>
</div> <!-- / #search-facets -->
[% IF ( OPACResultsSidebar ) %]
<div id="opacresultssidebar">
[% OPACResultsSidebar | $raw %]
</div>
[% END %]
[% END # / IF opacfacets && facets_loop %]