Skip to content

Commit

Permalink
show selected filters on first position in facet
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-sc committed Feb 3, 2025
1 parent 7c45fb1 commit fb89741
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Classes/Common/QueryParamsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ private static function retrieveFilterParamsForEntityType(
// show docs with count 0 only for multiple select fields
'min_doc_count' => $entityTypeMultiselect ? 0 : 1,
'size' => $entityTypeSize,
// 'include' => 'Slowakisch|.*',

]
]
],
Expand Down
5 changes: 5 additions & 0 deletions Classes/ViewHelpers/ProcessFacetsViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public static function renderStatic(
return $item['doc_count'] > 0 || ($item['selected'] ?? false);
});

// Sort the array so that selected items come first
usort($returnBucket, function ($a, $b) {
return ($b['selected'] ?? false) <=> ($a['selected'] ?? false);
});

return $returnBucket;

}
Expand Down

0 comments on commit fb89741

Please sign in to comment.