Display Result Sort Options in a Dropdown
Display Result Sort Options in a Dropdown
Legacy feature
This article pertains to the Coveo Hive framework which is now in maintenance mode. Choose one of Coveo’s more modern, lightweight, and responsive libraries for any future search interface development. See the search interface Implementation guide for more details. |
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, if you want to provide several sorting options to your users, having one button per sort criterion can clutter the search interface. Displaying all sort options in a dropdown list then becomes a useful alternative.
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 first
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
toDescending
. -
Set the
Caption
toNewest first
.
-
-
Configure the
Oldest first
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, 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 directions
option. -
Set the
Sort direction
toAscending
. -
Set the
Caption
toOldest first
.
-
-
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.