Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Jeroen Oostwouder 63 posts 159 karma points
    Aug 28, 2015 @ 08:34
    Jeroen Oostwouder

    Randomize a list of Children (DynamicNodeList)


    I want a list of items (nodes) to display on a page in a random order. Is there any way to do that?

    I tried


    But that only returns 1 item.

    I've also tried something like this:

    node.ChildrenAsList.Where("show").OrderBy(x => Guid.NewGuid());

    But that results in an error too, because I can't use a lambda expression there.

    Any other ideas? I can't be the first that needs to shuffle a list of nodes, can I?

  • Benas Brazdziunas 34 posts 155 karma points c-trib
    Oct 01, 2015 @ 14:24
    Benas Brazdziunas

    It your node is CurrentPage you can use Model.Content instead:

    var random = Model.Content.Children.Where("show").OrderBy(x => Guid.NewGuid());
  • Stuart Nisbett 11 posts 56 karma points
    Aug 17, 2018 @ 11:47
    Stuart Nisbett

    easiest way is to use .Random(#) Replace # with the number of results or to display all - if there aren't too many - put in a number which will cover the lot.

Please Sign in or register to post replies

Write your reply to: