@{
var ceremonie = Model.Root().DescendantsOrSelfOfType("ceremonie");
foreach (var item in ceremonie.OrderBy(x => Guid.NewGuid()).Take(1))
{
YOUR CODE HERE
}
}
//show random ceremonie
//get ceremonieList
var ceremoniesList = Model.Root().DescendantsOfType("ceremonie1");
//radomize and pick one
var randomCeremonie = ceremoniesList.OrderBy(x => Guid.NewGuid()).FirstOrDefault();
//check if exist
if(randomCeremonie != null) {
//pass item to ceremoniecard partial view
@Html.Partial("~/Views/Partials/CeremonieCard.cshtml", randomCeremonie)
}
Just beware of the performance of this solution. In ordrer to do the DescendantsOfType(...) all published items are evaluated. The more content you publish, the more work is being done.
If you can, you should definetly use examine to find your “ceremonial”s.
Get single random item
Hi,
This returns a single item. Perfect. But how do i get a random single item in v8?
Thanks!
Hi!
The way I make it work was like this :
This is my working solution:
Just beware of the performance of this solution. In ordrer to do the DescendantsOfType(...) all published items are evaluated. The more content you publish, the more work is being done.
If you can, you should definetly use examine to find your “ceremonial”s.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.