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 →

Category list of child pages

Started by Dmitry 7 years ago · 1 replies · 1288 views
7 years ago

Hello! I have a list of pages:
{% set items = page.evaluate({'@page.children': '/items'}) %}

How can I get a list of categories for these pages?

7 years ago

My decision now:

TWIG
{% set items = page.evaluate({'@page.children': '/items'}) %}
{% set catlist = [] %}

{% for item in items %}
    {% for cat in item.taxonomy.category %}
        {% if cat not in catlist %}
            {% set catlist = catlist|merge([cat]) %}
        {% endif %}
    {% endfor %}
{% endfor %}

Suggested topics

Topic Participants Replies Views Activity
General · by Sergi, 2 days ago
1 63 1 day ago
General · by themetman, 4 days ago
2 91 4 days ago
General · by Hanns Mattes, 2 weeks ago
0 147 2 weeks ago
General · by Karmalakas, 2 weeks ago
2 217 2 weeks ago
General · by Hanns Mattes, 4 weeks ago
0 278 4 weeks ago