我为我的“主要内容”创建了一个块,这个块使用转发器字段来添加多个按钮。
它在我的前端正确呈现,但按钮不包含在 Twill 的内容编辑器中。
当我从mainContent.blade.php中删除 @yield和从buttons.blade.php中删除 @section 时,按钮确实会显示在前端和内容编辑器中,但它们将被添加到我的 mainContent 块之外。
如何让按钮显示在 Twill 的拖放内容编辑器中?
意见/管理/块/mainContent.blade.php
@twillBlockTitle('MainContent')
@twillBlockIcon('text')
...
@formField('repeater', [
'type' => 'buttons',
'name' => 'button_repeater'
])
视图/管理员/中继器/buttons.blade.php
@twillRepeaterTitle('Buttons')
@twillRepeaterMax('4')
@formField('input', [
'name' => 'label',
'label' => 'Button text'
])
@formField('input', [
'name' => 'url',
'label' => 'Button url',
'fieldNote' => 'https://google.com/'
])
@formField('select', [
'name' => 'type',
'label' => 'Button type',
'placeholder' => 'Select a button type',
'options' => [
[
'value' => 'btn-primary',
'label' => 'Primary'
],
[
'value' => 'btn-secondary',
'label' => 'Secondary'
],
[
'value' => 'btn-link',
'label' => 'Link'
],
]
])
@formField('input', [
'name' => 'fa_icon',
'label' => 'Font Awesome icon code',
'fieldNote' => 'fa-users'
])
视图\站点\块\mainContent.blade.php
<section class="block block-main-content">
<div class="container">
<div class="row">
<div class="col-12 col-lg-6">
<h2>{{ $block->input('title') }}</h2>
<p>{{ $block->input('content') }}</p>
@yield('buttons')
</div>
<div class="col-12 col-lg-6">
<img class="img-fluid" src="{{ $block->image('image', 'desktop') }}" />
</div>
</div>
</div>
</section>
视图\站点\块\buttons.blade.php
@section('buttons')
<a href="{{ $block->input('url') }}" class="{{ $block->input('type') }} btn">
@if (!empty($block->input('fa_icon')))
<i class="fa {{$block->input('fa_icon')}}"></i>
@endif
<span>
{{ $block->input('label') }}
</span>
</a>
@append