Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

contentMeta is NULL while looping through a collection

Solved by Nico Petri View solution

Started by Nico Petri 8 years ago · 2 replies · 681 views
8 years ago

Hi there,

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

TWIG
{% 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:

TXT
[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

last edited 07/09/18 by Nico Petri
8 years ago Solution

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

8 years ago

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

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 96 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 184 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 147 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 61 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 255 1 year ago