I am using the approach suggested by the Kirby Builder plugin’s docs: small snippets (one for each block type), and within those I make use of Kirby’s chaining syntax to work with the data.
Now, I have a few instances in my templates where I would like to call the same snippets directly (i.e. without involvement of the builder). Use case: While users can add a “Donation banner” block using the builder, I also want to hardcode them into a few pages’ templates by default. This breaks as soon as the snippets contain the processing of variables, e.g.
<?= $data->calltoaction() ?>.
This shouldn’t be too difficult, but I am terribly stuck with how to achieve this. I would like to be able to call a custom page method (e.g.
builderblock()) as follows and it would render the block snippet
donate, dealing with the data as if it were handed over by the plugin’s
toBuilderBlocks() method, i.e. enabling all the same chaining operations etc.
$page->builderblock([ '_key' => 'donate', 'content' => [ 'calltoaction' => 'Donate now', 'img' => 'donation.svg' ] ])
How do I get this content handed over to the snippet in the same format as the Builder plugin does? Any hints in the right direction would be greatly appreciated!