How to access the categories from this array to display on my custom page

Viewed 71

I want to access page.categories.entities.elements->in that how to deal with these id's not getting

Here is the screenshot attached:

here is the screenshot attached

2 Answers

You can access it using keys filter in twig.

{% set keys = page.categories.entities.elements|keys %}
{% set data = page.categories.entities.elements[keys[0]] %}
{{ dump(data) }}

We can do it like this also:

{% set categories = page.categories %}
 {% for category in categories %}
<li>{{ category.translated.name }}</li>
{% endfor %}
Related