Hey there. I noticed @texnixe opened this issue up on GitHub back in March, but while it’s in the hopper, I’m wondering if someone could help me solve this another way. Basically, here’s the idea:
I have a structure field set up that asks for a couple pieces of information (name, image, etc), and what I want to do is have it so, on page load, the site picks a random entry in the structure and displays that information.
I’ve tried various versions of
->shuffle() moved to different spots) but either it doesn’t work (breaks the page) or simply displays the first one in the structure (ignoring the shuffle).
Could I get a pointer of an alternate way to solve this? I can count the number of fields in that structure and generate a random number based on that, but I’m not sure how to select that specific thing out of the structure.
$luckies = $page->lucky_people()->toStructure()->count(); $r = rand(1, $luckies); $randomLucky = $page->lucky_people()->toStructure()->children($r);
…except not that, because that’s failing to work.