-
Improve the Experience
- Create a Simple Result List
- Add Related Controls
- List Result Sort Options in a Dropdown
- Toggle Between a List and a Card Result Layout
- Insert a Category Facet
- Override Coveo for Sitecore Hive Initialization Options
- Use Custom Initialization Scripts
- Pass Non-Fronted JavaScript Framework Properties to Hive Components
- Configure Custom Ranges for Range Facets
- Insert and Customize a Distance Resources Component
- Use Sitecore Personalization With Coveo
- Duplicate a Coveo for Sitecore Component to Modify Its HTML
- Create Custom Components
List Result Sort Options in a Dropdown
The Add Related Controls article describes how you can add search result sort controls to your search interface. When you follow these instructions, one sort button by rendering is added and, when both sort directions are enabled in the rendering data source, clicking successively on the button in the search interface toggles the sort direction.
However, enabling the Results Sorts Section Enable sort dropdown
data source option replaces side-by-side sort option buttons with a single drop-down list that contains all result sorting options you want to make available.
This article describes how to manage date sort and field sort options, and their captions, in a sort drop-down list presentation.
Default Caption for Date and Field Sort Options
When the Enable both sort directions
option is enabled on date sort or field sort options, Descending
and Ascending
will be appended to the Caption
option value.
For example, when the Date Sort
data source caption is Date
, the dropdown will have Date Descending
and Date Ascending
options.
Dictionary items have been created for Descending
and Ascending
and are available at the following location: /sitecore/system/Dictionary/Coveo Hive/Search Sections/
.
You can version them as needed to support multiple languages.
Custom Caption for Date and Field Sort Options
When the predefined caption format does not meet your requirements, it is possible to create custom captions.
For example, to create a date based sort displaying Newest
and Oldest
, using the following procedure:
-
In the Sitecore Experience Editor,
-
Configure the
Oldest
Coveo Date Sort-
In the Sitecore Experience Editor, select the existing Coveo Date Sort rendering.
-
In the floating toolbar, select the Edit the rendering’s data source option. It should be the leftmost option in the toolbar.
-
Uncheck the
Enable both sort directions
option. This option is responsible for appendingDescending
orAscending
after the definedCaption
option. -
Set the
Sort direction
toAscending
. -
Set the
Caption
toOldest
.
-
-
Configure the
Newest
Coveo Date Sort-
Select the Sorts placeholder above your existing Coveo Date Sort rendering.
-
Select Add here and select Coveo Date Sort in the Select a Rendering window.
-
In the Select the Associated Content window, select Create New Content and choose the parent you prefer.
-
Save the page.
-
In the floating toolbar of the Coveo Date Sort you just created, select Edit the rendering’s data source.
-
Uncheck the
Enable both sort directions
option. -
Set the
Sort direction
toDescending
. -
Set the
Caption
toNewest
.
-
-
Select the Results Sort Section rendering.
-
In the floating toolbar, select the Edit the rendering’s data source option.
-
Check the
Enable sort dropdown
option. -
You’re now ready to test your new sorts.
