Display result sort options in a dropdown
Display result sort options in a dropdown
|
|
Legacy feature
The Coveo Hive Framework is now in maintenance mode and is no longer recommended for new implementations. To build new search experiences, use one of Coveo’s more modern, lightweight, and responsive libraries. To get started, see the Build search article. |
The Add Related Controls article describes how you can add search result sort controls to your search interface. By default, one sort button per rendering is added and, when both sort directions are enabled in the rendering data source, clicking the button toggles the sort direction.
However, having one button per sort criterion to provide several sorting options can clutter the search interface. Displaying all sort options in a dropdown list then becomes a better solution.
Two Ways to Display Sort Options
Enabling the Enable sort dropdown data source option of the Results Sorts Section rendering replaces side-by-side sort option buttons with a single dropdown list that contains all result sorting options you want to make available.
|
|
Note
When choosing |
Default Captions for 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 list will have Date Descending and Date Ascending options.
|
|
Note
Coveo for Sitecore packages add dictionary items for the |
Custom Captions for a Specific Sort Option
You can create custom captions on a per sort option basis.
To create a date based sort displaying the Newest first and Oldest first options
-
Configure the
Newest firstCoveo 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 directionsoption. This option is responsible for appendingDescendingorAscendingafter the definedCaptionoption. -
Set the
Sort directiontoDescending. -
Set the
CaptiontoNewest first.
-
-
Configure the
Oldest firstCoveo 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, create the data source item in your preferred location.
-
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 directionsoption. -
Set the
Sort directiontoAscending. -
Set the
CaptiontoOldest first.
-
-
Select the Results Sort Section rendering.
-
In the floating toolbar, select the Edit the rendering’s data source option.
-
Check the
Enable sort dropdownoption. -
You’re now ready to test your new sorts.