Display Result Sort Options in a Dropdown

Warning
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.

Enable sort dropdown disabled versus enabled | Coveo for Sitecore 5
Note

When choosing Relevancy as the sort criterion, the Enable both sort directions option has no effect. You can only sort results from the most relevant to the least.

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 Descending and Ascending key captions in /sitecore/system/Dictionary/Coveo Hive/Search Sections/. You can override these captions (that is, the Phrase field value) using the Additional Dictionaries data source option of the Coveo Search Resources rendering. Version your custom dictionary items as needed to support multiple languages.

Custom Captions for a Specific Sort Option

You can create custom captions on a per sort option basis.

EXAMPLE

To create a date based sort displaying the Newest first and Oldest first options

  1. Configure the Newest first Coveo Date Sort:

    1. In the Sitecore Experience Editor, select the existing Coveo Date Sort rendering.

    2. In the floating toolbar, select the Edit the rendering’s data source option. It should be the leftmost option in the toolbar.

    3. Uncheck the Enable both sort directions option. This option is responsible for appending Descending or Ascending after the defined Caption option.

    4. Set the Sort direction to Descending.

    5. Set the Caption to Newest first.

      Image of the Coveo Date Sort rendering data source | Coveo for Sitecore 5
  2. Configure the Oldest first Coveo Date Sort.

    1. Select the Sorts placeholder above your existing Coveo Date Sort rendering.

    2. Select Add here and select Coveo Date Sort in the Select a Rendering window.

    3. In the Select the Associated Content window, create the data source item in your preferred location.

    4. Save the page.

    5. In the floating toolbar of the Coveo Date Sort you just created, select Edit the rendering’s data source.

    6. Uncheck the Enable both sort directions option.

    7. Set the Sort direction to Ascending.

    8. Set the Caption to Oldest first.

      Image of the Coveo Date Sort rendering data source | Coveo for Sitecore 5
  3. Select the Results Sort Section rendering.

  4. In the floating toolbar, select the Edit the rendering’s data source option.

  5. Check the Enable sort dropdown option.

  6. You’re now ready to test your new sorts.

    Date sort Newest first and Oldest first | Coveo for Sitecore 5