contentMeta is NULL while looping through a collection


#1

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 %}
  <h3>{{_s.headline}}</h3>
  ...
  ...
{% endfor %}

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

Structure is like that:

[01.home]
  ...
  [ _spotlight]
     [ _item1]
       item.md
     [ _item2]
       item.md
     ...
   ...

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

Thanks in advance for any help.
np


#3

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


#4

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.