Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

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

Started by Clay 6 years ago · 1 replies · 653 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 webmasterodp, 4 days ago
4 115 3 days ago
Support · by nwhitfield, 5 days ago
2 101 5 days ago
Support · by stell, 2 weeks ago
5 345 1 week ago
Support · by gravinator, 1 month ago
5 541 1 week ago
Support · by Gravver, 3 weeks ago
6 335 3 weeks ago