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 |
|---|---|---|---|---|
| 1 | 123 | 2 days ago | ||
| 5 | 195 | 2 days ago | ||
| 0 | 45 | 3 days ago | ||
| 0 | 44 | 3 days ago | ||
| 3 | 92 | 3 days ago |