I’m struggling to display content from the wonderful Builder plugin outside of the foreach loop used for calling the blocks.
I have a field called
mix that has a subfield called
title. I want to display the title in
My article.yml blueprint defines all the fields:
fields: content: builder: label: Page Builder type: builder fieldsets: mix: label: Mix fields: info: type: text label: Title upload: type: files multiple: false label: Upload mix layout: list query: page.audio textarea: label: Paragraph fields: textarea: type: textarea size: medium label: Paragraph
In article.php, the
foreach loop outputs all the content I build:
<?php foreach($page->builder()->toBuilderBlocks() as $block): ?> <?php snippet('blocks/' . $block->_key(), array('data' => $block)) ?> <?php endforeach ?>
And it works just fine. However, when I try to get the contents of the subfield
info to display in nav.php, it doesn’t work:
<div class="ticker-wrap"> <?php foreach($page->builder()->toBuilderBlocks()->data() as $block): ?> <?php foreach($block->mix() as $ticker): ?> <?= $ticker->info() ?> <?php endforeach ?> <?php endforeach ?> </div>
I get the debug message
Call to a member function info() on null.
I can’t wrap my head around what happens between
data and would greatly appreciate some assistance.
Thanks in advance!