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 · 799 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 lynbor, 3 weeks ago
3 352 3 days ago
General · by lynbor, 1 week ago
7 387 3 days ago
General · by Harry, 3 days ago
0 83 3 days ago
General · by Old Man Umby, 3 weeks ago
2 256 2 weeks ago
General · by jeremycherfas, 3 weeks ago
5 374 2 weeks ago