Quick Tip: “Randomly” Sorting Content in Native Widgets

Quick Tip: “Randomly” Sorting Content in Native Widgets

November 20, 2013 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

Here’s a quick way to achieve a “random” sort using native Sitefinity widgets. This requires no custom code but is probably a completely “off label” use of the property involved. Moving on…

Locate the SortExpression field for the widget you want to modify. Using DynamicContent as an example, click “Edit” then click through to Advanced -> ControlDefinition -> Views -> DynamicContentMasterView. SortExpression can be found near the bottom of the list. 

Once you’ve located the field, paste the following expression there.

DateCreated.ToString().Substring((DateTime.Now.Second % 10), 4)

This returns a slightly different string (each second) that Sitefinity can use to sort the content by. I only tested this on the DynamicContent and BlogPosts widgets but don't see any reason it wouldn't work on anything with a SortExpression.

Please, let me know if it works for you. Enjoy!

Tim Williamson

View all posts from Tim Williamson on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments are disabled in preview mode.
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

More From Progress
ProgressNEXT: Premier Event for Modern Application Development
Read More
Seven Reasons to Check Out Sitefinity 11.1
Read More
Getting Started with Your Omnichannel Content Strategy
Read More