Skip to content
● Critical PHP security fixes are out: update PHP on your Grav sites. What to do →

Category list of child pages

Started by Dmitry 7 years ago · 1 replies · 857 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, 1 month ago
5 540 5 days ago
General · by Andy Miller, 2 weeks ago
0 230 2 weeks ago
General · by lynbor, 4 weeks ago
7 658 3 weeks ago
General · by Harry, 3 weeks ago
0 233 3 weeks ago
General · by Old Man Umby, 1 month ago
2 367 1 month ago