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

Category list of child pages

Started by Dmitry 7 years ago · 1 replies · 818 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 peterparker08, 1 hour ago
0 9 1 hour ago
General · by Andy Miller, 4 days ago
0 85 4 days ago
General · by lynbor, 4 weeks ago
3 423 2 weeks ago
General · by lynbor, 3 weeks ago
7 539 2 weeks ago
General · by Harry, 2 weeks ago
0 149 2 weeks ago