How to Automatically Sort Items in Sitecore CMS

May 27, 2015

Blog | Development | How to Automatically Sort Items in Sitecore CMS
How to Automatically Sort Items in Sitecore CMS

Welcome back to our series about learning how to use and develop for Sitecore. This is the follow-up post to “How to Manually Sort Items in Sitecore CMS”.

All items in Sitecore have a “Subitems Sorting” field which can be used to select a sorting method for the item’s children. Today, we’ll look at how to automatically sort items using this field.

Items are ordered based on their “Sortorder” field, and then by a secondary method. The default sort orders items based on the item names. Other options include:

  • Creation date
  • Display name
  • Logical by name (1, 2, 10 instead of 1, 10, 2)
  • Reverse by name
  • Updated date

Subitems sorting can be changed on a per-item basis, but is generally best assigned on __Standard Values so that subitems of each template type are sorted consistently.

From the Ribbon

Select the item whose children should be sorted.

Click the “Sorting” section label on the “Home” tab of the ribbon.

A modal will appear titled “Set the Sorting for the Subitems”.

The modal will display a dropdown where the various sorting options are available. Below the dropdown is a preview of how the child items would be sorted. Selecting different sort methods in the dropdown will update the preview.

The reset button at the bottom left of the modal can be used to reset the Sortorder of all the child items back to their default value.

Note

Resetting the sort order will assign the default sort order value from the web.config rather than resetting the Sortorder fields to their standard values. If you want to reset Sortorder fields to their standard values you will need reset each item’s field manually.

Clicking “OK” in the modal will set the new subitems sorting.

From the Context Menu

Right-click the item whose children should be sorted.

In the “Sorting” menu of the context menu that appears, select the “Subitems Sorting” option.

The “Set the Sorting for the Subitems” modal will appear again. Select the appropriate sorting method, and click “OK” when finished.

From the Subitems Sorting Field

Select the item whose children should be sorted.

In the “Appearance” template section, update the “Subitems Sorting” field to the appropriate sorting method.

Save the changes.


Thanks for checking in. As always, if you have any questions or if there’s something you’d like to see us cover, drop us a line!

Tim Leverett

Senior Developer
Tags
  • Sitecore
  • Tutorial
Sitecore Survival Guide Volume 1

If you found this post helpful, there are plenty more where it came from! You'll find the first 10 here.

Download the first 10 posts in our Sitecore how-to series by Developer Tim Leverett!

Recent Work

Check out what else we've been working on