Render repeater in block blade file
I have made a block named "gallery" with a repeater containing medias named "gallery-item", please help me to display the images in the blade file of the block. (I tried with regular block with {{ $block->image(...) }} but don't know how to do with blocks with repeaters).
I tried this example but it doesn't work: https://twillcms.com/docs/block-editor/creating-a-block-editor.html#content-rendering-helpers
Thank you very much.
PB
Patrick Boivin•366d ago
Hi @hoanghnguyen, I haven't used this in a while but if I remember correctly, repeaters inside of blocks are saved as child blocks. You should be able to do something like this :
Not sure about the new blade helpers... Does this:
$repeaterItem->renderData->block->image(...)
not work for you?H
hoanghnguyen•365d ago
Thank you very much @pboivin, I modified my code based on your answer and this works for me:
@foreach($block->children as $repeaterItem)
<img src="{{ $repeaterItem->image('gallery-item') }}" alt="" />
@endforeach
--------
This doesn't work for me in my case... or maybe because I don't know how to define $repeater...
@foreach ($repeater('gallery-item') as $repeaterItem)
<li>
<img src="{{ $repeaterItem->renderData->block->image('slider', 'desktop', ['h' => 850]) }}" alt="">
{{ $repeaterItem->renderData->block->input('title') }}
</li>
@endforeach
G
geetpurwar•344d ago
@hoanghnguyen Did you find any solution?
1.4KMembers
View on DiscordWant results from more Discord servers?
More PostsFetch all images in a blockHow do you fetch all the images in a block? For e.g i have this block <x-twill::medias
name="slRepeater without blocksHow do you add and render a repeater without including it in the block?Adding custom blocks to modulesHow do you add custom blocks to modules? Generally i add blocks to a module using $form->add(BlockEd$renderData returns null when trying to render nestedblocks@php
/** @var \A17\Twill\Services\Blocks\RenderData $renderData */
dd($renderData)
Fetch all models with field value of XSorry to ask such a basic question but I want to do the following....
I have a model called Work (anDisplaying Block elements on the Front Pagehow do you display block elements on the frontpage? And i don't mean the preview file. I want to accdashboard routeHello. I have a problem with dashboard config
I have a Category and CategoryArticle Models
I have aTwill Role based accessHow would i go about adding a Role based access to CMS Components and its entries. For e.g in an imaTwill assets errorHello to everyone i have an website in production builded in twill but some twill assets in there aWhere to find block repositories?I've seen in the tutorial(https://www.youtube.com/watch?v=kAcJ5G2GhiA) some blocks like "paragraph &