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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

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

Started by Clay 6 years ago · 1 replies · 490 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 Thomas, 1 week ago
2 53 11 hours ago
Support · by Anna, 3 days ago
2 60 13 hours ago
Support · by Justin Young, 14 hours ago
1 30 14 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 56 5 days ago