Hi, this is my first question here.
I read through various forum posts, but none of the solutions have worked for me. My toStructure() code keeps coming up null.
This is the toStructure field in my blueprint:
stories:
label: Stories
type: structure
fields:
story:
label: Story
type: text
link:
label: Link
type: url
which produces this format:
Stories:
-
story: There once was a dog who drove a car.
link: 'https://example1.com'
-
story: There once was a cat who flew a plane.
link: 'https://example2.com'
I tried the code from $field->toStructure() and changed it like so:
<?php foreach (page('history')->children()->stories()->toStructure() as $story): ?>
<a href="<?= $story->link() ?>">
<?= $story->story() ?>
</a>
<?php endforeach ?>
but it comes up null. I can get regular field data to show up in the template, but not the structured field data.
How to do render the data from the structure field in the template?