Hi,
I'm writing a front-end for my Twill project. I have successfully managed to output block content on a single module page on my front-end, but in the case of repeaters the child blocks render after their parent- whereas I want them to render between the parent's opening and closing HTML tags. How do I go about doing this?
Many thanks,
Seb
Hi Seb,
you can opt-out from rendering children as separate views in repeater blocks when using the renderBlocks helper:
$item->renderBlocks(false)
Child blocks are then accessible through the $block->children relationship, so that you can loop over them inside the parent block view.
You do not have to opt-out from rendering children if you need to keep it somehow, you can render everything in the parent block and leave all child views empty, but that's a bit more clunky than simply opting-out to avoid having to create useless child views.
Perfect, thanks again! $block->children was what I was looking for.