Don't miss out Virtual Happy Hour this Friday (April 26).
Try our conversational search powered by Generative AI!
AI OnAI Off
Don't miss out Virtual Happy Hour this Friday (April 26).
Pick a random content area item:
public virtual ContentArea ContentArea { get; set; }
public ContentAreaItem RandomItem
{
get
{
var random = new Random();
return ContentArea?.FilteredItems.OrderBy(x => random.Next()).FirstOrDefault();
}
}
An alternative approach would be to make a Random Visitor Group and then personalising the blocks in the content area.
var random = new Random(unchecked((int)(DateTime.Now.Ticks)));
IList<ContentAreaItem> randomItemsList = contentAreaItemsList.OrderBy(t => random.Next(contentAreaItemsList.Count)).ToList();
I thought you wanted to pick one content area item randomly.
Your own answer, that you accepted as the answer, returns all items in random order.
I have added a number of blocks as contentArea Items in a ContentArea property.
I need to randomly pick a contentarea item and display it.
I don't want it in the order its mentioned in the contentarea
Please Help!!!