I have an article page that has a block field containing text, headings and images. For the frontend of the overview page I’d like to access the first text block from the blocks field. Is this possible and how would I go about this?
Yes, of course. Assuming you are looping through the children on the parent:
<?php foreach ($page->children()->listed() as $article): ?>
<?php if ($block = $article->nameOfBlocksField()->toBlocks()->filterBy('type', 'text')->first()): ?>
<?= $block ?>
<?php endif ?>
<?php endforeach ?>
1 Like
Wauw thanks again Sonja!