Hi guys,
How can I order by "Facets" in the new index?
I can't find any option in the backoffice.
Best,
Ricardo Pereira
Hi guys,
How can I order by "Facets" in the new index?
I can't find any option in the backoffice.
Best,
Ricardo Pereira
Hi Ricardo,
I'm not sure I understand what you're trying to do.
Are you trying to sort the list of facet options for your facets or are you trying to sort the result set?
- Jeppe
Hi Jeppe,
I'm trying to sort the list of facet options (GetLoop("Facets")) in the backend.
The facet options for field facets are sorted alphabetically by default. There's no option to change the sorting for this facet type. You can use a Razor template to change the order in which they are rendered by doing something like this.
// Assume 'facet' is a LoopItem from the 'GetLoop("Facets")' loop // This code will reverse the sort order of the facets, but you can create your own lambda instead var facetOptionsOrdered = facet.GetLoop("FacetOptions").OrderByDescending(optionLoopItem => optionLoopItem.GetString("FacetOption.Label")); foreach (LoopItem facetOption in facetOptionsOrdered) { // Render facet options here }
- Jeppe
Thank you Jeppe.
It would be interesting if we could sort the filters in backend "defined by user".
Maybe I misunderstood you.
Are you talking about the order of the facets or the order of the facet options?
Consider two facets: Color and Size. For Color, there are three values: Red, Green, Blue. For Size, there are two options: Small, Large.
In this example, do you want to specify how Color and Size are sorted or do you want to specify how "Red, Green, Blue" and "Small, Large" are sorted?
I want sort the color and size.
The sort order of these elements are exactly the same as in the UI.
You can either add the facets in the order you want to display them at design time, or you can use the Razor template to decide the order. There is another option if you don't want to use the Razor template to control this. You can edit the order directly in the configuration file. That file is located inside your repository folder here: /Files/System/Repositories/<RepositoryName>/<FacetGroupName>.facets. Simply change the order of the facets to the order you want.
Changing the file solves the problem, but would be good if we could change the sort of the facets in the backend.
Thank you Jeppe
We will be doing an overhaul of the UI at some point in the near future. I'll keep it in mind.
You must be logged in to post in the forum