Created
September 9, 2013 18:13
-
-
Save csharpforevermore/6499384 to your computer and use it in GitHub Desktop.
In Umbraco Razor, sometimes it is necessary to get a random few nodes. This example allows you to get a random collection of child nodes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// take specific amount from randomised collection of the children | |
var children = CurrentModel.Children; | |
var random = new Random(); | |
var shuffled = children.OrderBy(i => random.Next()).ToList().Take(childCount); | |
children = new DynamicNodeList(shuffled); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment