@@ -, +, @@ a. on the OPAC side, you should get OPAC text in the facets b. on the staff side, you should get staff text --- C4/Koha.pm | 55 ++++++++++++++------ C4/Search.pm | 11 +++- .../intranet-tmpl/prog/en/includes/facets.inc | 1 + .../opac-tmpl/prog/en/includes/opac-facets.inc | 2 + opac/opac-search.pl | 2 +- 5 files changed, 51 insertions(+), 20 deletions(-) --- a/C4/Koha.pm +++ a/C4/Koha.pm @@ -24,6 +24,7 @@ use strict; #use warnings; FIXME - Bug 2505 use C4::Context; use C4::Output; +use C4::Branch qw(GetBranchesLoop); use URI::Split qw(uri_split); use Memoize; use Business::ISBN; @@ -677,6 +678,7 @@ sub getallthemes { sub getFacets { my $facets; + my @branchloop = GetBranchesLoop(); if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) { $facets = [ { @@ -714,14 +716,24 @@ sub getFacets { my $library_facet; - $library_facet = { - link_value => 'branch', - label_value => 'Libraries', - tags => [ '995', ], - subfield => 'b', - expanded => '1', - }; - push @$facets, $library_facet unless C4::Context->preference("singleBranchMode"); + if (@branchloop > 1) { + $library_facet = { + link_value => 'branch', + label_value => 'Libraries', + tags => [ '995', ], + subfield => 'b', + expanded => '1', + }; + } else { + $library_facet = { + link_value => 'location', + label_value => 'Location', + tags => [ '995', ], + subfield => 'c', + expanded => '1', + }; + } + push @$facets, $library_facet; } else { $facets = [ @@ -764,14 +776,25 @@ sub getFacets { }, ]; my $library_facet; - $library_facet = { - link_value => 'branch', - label_value => 'Libraries', - tags => [ '952', ], - subfield => 'b', - expanded => '1', - }; - push @$facets, $library_facet unless C4::Context->preference("singleBranchMode"); + if (@branchloop > 1) { + $library_facet = { + link_value => 'branch', + label_value => 'Libraries', + tags => [ '952', ], + subfield => 'b', + expanded => '1', + }; + } else { + $library_facet = { + link_value => 'location', + label_value => 'Location', + tags => [ '952', ], + subfield => 'c', + expanded => '1', + }; + } + + push @$facets, $library_facet; } return $facets; } --- a/C4/Search.pm +++ a/C4/Search.pm @@ -287,13 +287,13 @@ sub SimpleSearch { $koha_query, $simple_query, $sort_by_ref, $servers_ref, $results_per_page, $offset, $expanded_facet, $branches, - $query_type, $scan + $query_type, $scan, $opac ); The all singing, all dancing, multi-server, asynchronous, scanning, searching, record nabbing, facet-building -See verbse embedded documentation. +See verbose embedded documentation. =cut @@ -301,7 +301,7 @@ sub getRecords { my ( $koha_query, $simple_query, $sort_by_ref, $servers_ref, $results_per_page, $offset, $expanded_facet, $branches, - $query_type, $scan + $query_type, $scan, $opac ) = @_; my @servers = @$servers_ref; @@ -562,6 +562,11 @@ sub getRecords { } } + # also, if it's a location code, use the name instead of code + if ( $link_value =~ /location/ ) { + $facet_label_value = GetKohaAuthorisedValueLib('LOC', $one_facet, $opac) || '*'; + } + # but we're down with the whole label being in the link's title. push @this_facets_array, { facet_count => $facets_counter->{$link_value}->{$one_facet}, --- a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc @@ -16,6 +16,7 @@ [% IF ( facets_loo.type_label_Places ) %]Places[% END %] [% IF ( facets_loo.type_label_Series ) %]Series[% END %] [% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %] +[% IF ( facets_loo.type_label_Location ) %]Locations[% END %]