Displaying Block elements on the Front Page
how do you display block elements on the frontpage? And i don't mean the preview file. I want to access the block elements like $item->block like that.
5 Replies
$item->blocks is a collection of blocks
so would $item->blocks('ckeditor')->render() would do the trick? because it doesn't for me
no that would be
$item->renderBlocks()
or renderNamedBlocks('block_editor_field_name')
what are you trying to do with that ckeditor parameter though? Is that the name of one of your blocks?yes
for instance i have a wysiwig editor and an image and a textbox in the blockeditor. I want to render all three of them in my template
so a subselection of blocks by their type? In that case you can do
$item->blocks->whereIn('type', [...])->get()
and iterate over that collection to include the view you want to render for each block type.