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 | 93 | 4 days ago | ||
| 1 | 265 | 3 weeks ago | ||
| 4 | 380 | 1 month ago | ||
| 2 | 351 | 1 month ago | ||
| 5 | 657 | 1 month ago |