Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

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

Started by Clay 6 years ago · 1 replies · 768 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 TomW, 2 weeks ago
8 227 9 hours ago
Support · by alex, 2 months ago
8 667 24 hours ago
Support · by Supple, 5 days ago
1 98 1 day ago
Support · by TomW, 1 week ago
3 159 3 days ago
Support · by TomW, 6 days ago
2 106 5 days ago