Given a collection -i.e.-:
page.find('/blog').collection({'items': '@self.descendants','order': {'by': 'date','dir': 'desc'}})
Is it possible to get a random page from that collection inside a twig template?
Thanks,
Community guidelines
Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.
Given a collection -i.e.-:
page.find('/blog').collection({'items': '@self.descendants','order': {'by': 'date','dir': 'desc'}})
Is it possible to get a random page from that collection inside a twig template?
Thanks,
as your collection is an array, you could adapt this example to your need:
https://learn.getgrav.org/cookbook/twig-recipes#picking-a-random-item-from-a-translated-array
Log in to reply.
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 2 | 53 | 9 hours ago | ||
| 2 | 59 | 12 hours ago | ||
| 1 | 30 | 13 hours ago | ||
| 2 | 65 | 5 days ago | ||
| 2 | 56 | 5 days ago |