Hello,
usually I use Kirby Builder with the documented foreach
loop, which works perfectly:
<?php # /site/templates/yourtemplate.php foreach($page->mybuilder()->toBuilderBlocks() as $block): snippet('blocks/' . $block->_key(), array('data' => $block)); endforeach; ?>
This time, I would like to output only the content of a single block without using the loop. I tried to modify the code and call just one snippet, but can’t seem to get it to work.
This is my code to get the second block of my page:
<?php $gallery = $page->mybuilder()->toBuilderBlocks(1); snippet('blocks/gallery', array('data' => $gallery)); ?>
It seems like this doesn’t provide the right data, because if I try to work with $data in the block template, I always get Call to a member function toFiles() on null
errors. I guess the error should be pretty simple to fix, so any help is appreciated. Thanks!