i’m new to Kirby and can’t figure out how to acess my structure in the frontend.
thats part of my yml-file:
title: Home
sections:
home:
type: fields
fields:
news:
label: News
type: structure
min: 3
max: 3
sortBy: date
fields:
date:
label: Datum
type: date
headline:
label: Überschrift
type: text
text:
label: Text
type: textarea
image:
label: Bild
type: files
max: 1
min: 1
ans thats my php
<?php
// using the `toStructure()` method, we create a structure collection
$news = $page->news()->yaml();
var_dump($news);
// we can then loop through the entries and render the individual fields
foreach ($news as $new): ?>
<a class="news-date"><?= $new->date() ?></a>
<a class="news-title"><?= $new->headline()?></a>
<a class="news-description"><?= $new->text()?></a>
<?php endforeach ?>
As far as I can see its similar to the one in the docs. I really can’t find my mistake.
The var_dump shows array(0) { } for yaml() and object(Kirby\Cms\Structure)#284 (0) { } for toStructure()