how can I retrieve a single page from a page collection in one line?
TWIG
{% set second_page = page.children[1] %}
something like this?
how can I retrieve a single page from a page collection in one line?
{% set second_page = page.children[1] %}
something like this?
Yes you can do that, it will do that if your array is integer based. However, i don't 'think' collections are. One way to get around this is to use []notation but with the slice syntactic sugar:
{% set second_page = page.children[2:2] %}
does not work
Try dumping page.children and make sure you actually have children available:
{{ dump(page.children) }}
Log in to reply.
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 0 | 1350 | 9 years ago | ||
| 2 | 934 | 9 years ago | ||
| 2 | 4060 | 9 years ago | ||
| 1 | 2947 | 9 years ago | ||
| 3 | 1118 | 9 years ago |