contentMeta is NULL while looping through a collection

Hi there,

as above i try to retrive shortcode sections by using this code:

{% for _p in page.collection %}
  {% set _s = _p.contentMeta.shortcodeMeta.shortcode.section %}
{% endfor %}

But it doesn’t work. _s is null. When i dump _p itself even content and contentMeta is NULL.

Structure is like that:

  [ _spotlight]
     [ _item1]
     [ _item2]

I loop through the _items folders to retrieve the contentMeta for the _spotlight
modular page.

Thanks in advance for any help.

I got it, the error was related to a malformed section definition, thats why the contentMeta was empty.

Glad you solved it! In future we need much more info to solve a problem like this. A crucial one for Twig templates is which theme you are using.

1 Like