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,
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 |
|---|---|---|---|---|
| 13 | 219 | 8 hours ago | ||
| 2 | 127 | 3 days ago | ||
| 9 | 300 | 3 days ago | ||
| 4 | 165 | 6 days ago | ||
| 4 | 173 | 1 week ago |