In my previous Orchard CMS Tutorial, Projector Module in Orchard CMS, I mentioned the new Projector Module. I also mentioned how it was missing at least 1 important feature, the ability to return a random set of items from a query. This is important for those Orchard Websites where the client wants to rotate various information on the website like customer testimonials, clients, new products, products on sale, or any other content type where you want to spotlight a few random items from time-to-time. Well, the Orchard Developer Team heard this feeback and created a new Random Sort Criteria in the Projector Module.
When you create a new query using the Projector Module you now have the option of choosing Random order as a sort criteria. Shown below is an example of a possible query to grab a list of random testimonials for your Orchard Website.
The ability to choose a random order for the items to be returned by a query is the same as when you choose to sort by a particular record property, etc.
As mentioned in the previous tutorial, Projector in Orchard CMS, you can now easily create a projection or use the Projection Widget to display a list of items randomly on your Orchard Website.
If you are curious as to how the Projector Module is returning a list of random items, it is using order by newid() on the database server.
The new Random Sort Criteria added to the Projector Module in Orchard CMS is a welcome addition! I look forward to when the Projector Module is released with the new version of Orchard.