Skip to content
Grav 2.0 is officially stable. Read the announcement →
Support

Is there a better way to get a specific child page?

Started by Clay 6 years ago · 1 replies · 579 views
6 years ago

I want to work with a specific child page of my current page. The following "works", but seems clunky:

TWIG
{% for kid in page.children() %}
    {% if kid.slug == "slides" %}
        {% for img in kid.media.images %}
            {{ ... }}
        {% endfor %}
    {% endif %}
{% endfor %}

Is there no way to "filter" page.children() calls at the top to return only children that match some attribute? (ie, slug=="slides"?)

Thank you.

6 years ago

I think '@page.children': '/slides' or '@page.page': '/slides' should work. The first will get all the children of the 'slides' pages, while the second (I think) should get all the 'slides' pages themselves.

Suggested topics

Topic Participants Replies Views Activity
Support · by Paul Hodges, 4 weeks ago
19 484 5 days ago
Support · by Lauw, 7 days ago
2 99 7 days ago
Support · by Anna, 3 weeks ago
4 426 1 week ago
Support · by gtx, 4 weeks ago
4 377 3 weeks ago
Support · by Anna, 1 month ago
9 484 3 weeks ago