Bug 28826: Add FacetOrder system preference
This bug adds a system preference to control ordering of facets and adds the control to both Zebra and Elasticsearch To test: 1 - Have a koha that can use both Zebra and ES 2 - Set 'displayFacetCount' to true 3 - Search in ES and Zebra 4 - Note facets in Zebra sorted alphabetically, ES by usage 5 - Apply patch, updatedatabase 6 - Search in ES and Zebra, facets are alphabetically sorted in both 7 - Find new syspref FacetOrder and set to 'by usage' 8 - Search in both engines, facets sorted by usage Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
3d5ea8d426
commit
ef40ba17ae
5 changed files with 28 additions and 1 deletions
|
@ -586,7 +586,10 @@ sub getRecords {
|
|||
# This sorts the facets into alphabetical order
|
||||
if (@facets_loop) {
|
||||
foreach my $f (@facets_loop) {
|
||||
$f->{facets} = [ sort { uc($a->{facet_label_value}) cmp uc($b->{facet_label_value}) } @{ $f->{facets} } ];
|
||||
if( C4::Context->preference('FacetOrder') eq 'Alphabetical' ){
|
||||
$f->{facets} =
|
||||
[ sort { uc($a->{facet_label_value}) cmp uc($b->{facet_label_value}) } @{ $f->{facets} } ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -502,9 +502,14 @@ sub _convert_facets {
|
|||
type_link_value => $type,
|
||||
};
|
||||
}
|
||||
if( C4::Context->preference('FacetOrder') eq 'Alphabetical' ){
|
||||
@{ $facet->{facets} } =
|
||||
sort { $a->{facet_label_value} cmp $b->{facet_label_value} } @{ $facet->{facets} };
|
||||
}
|
||||
push @facets, $facet if exists $facet->{facets};
|
||||
}
|
||||
|
||||
|
||||
@facets = sort { $a->{order} <=> $b->{order} } @facets;
|
||||
return \@facets;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
$DBversion = 'XXX';
|
||||
if( CheckVersion( $DBversion ) ) {
|
||||
$dbh->do(q{
|
||||
INSERT IGNORE INTO systempreferences
|
||||
( variable, value, options, explanation, type ) VALUES
|
||||
('FacetOrder','Alphabetical','Alphabetical|Usage','Specify the order of facets within each category','Choice')
|
||||
});
|
||||
NewVersion( $DBversion, 28826, "Add system preference FacetOrder");
|
||||
}
|
|
@ -208,6 +208,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
|
|||
('ExtendedPatronAttributes','1',NULL,'Use extended patron IDs and attributes','YesNo'),
|
||||
('FacetLabelTruncationLength','20',NULL,'Specify the facet max length in OPAC','Integer'),
|
||||
('FacetMaxCount','20',NULL,'Specify the max facet count for each category','Integer'),
|
||||
('FacetOrder','Alphabetical','Alphabetical|Usage','Specify the order of facets within each category','Choice'),
|
||||
('FailedLoginAttempts','','','Number of login attempts before lockout the patron account','Integer'),
|
||||
('FallbackToSMSIfNoEmail', 0, 'Enable|Disable', 'Send messages by SMS if no patron email is defined', 'YesNo'),
|
||||
('FeeOnChangePatronCategory','1','','If set, when a patron changes to a category with enrolment fee, a fee is charged','YesNo'),
|
||||
|
|
|
@ -231,6 +231,15 @@ Searching:
|
|||
class: integer
|
||||
default: 20
|
||||
- facets for each category.
|
||||
-
|
||||
- Sort facets
|
||||
- pref: FacetOrder
|
||||
type: choice
|
||||
choices:
|
||||
Alphabetical: "alphabetically"
|
||||
Usage: "by usage count"
|
||||
default: Alphabetical
|
||||
- for each category.
|
||||
-
|
||||
- By default, show
|
||||
- pref: OPACnumSearchResults
|
||||
|
|
Loading…
Reference in a new issue