【问题标题】:Twill CMS (Laravel): How to set up Repeater blocks? Repeaters display at wrong placeTwill CMS (Laravel):如何设置中继器块?中继器显示在错误的位置
【发布时间】:2019-11-04 03:33:26
【问题描述】:

我想在我的新项目中使用斜纹布的中继器块,像在文档中一样设置它,但它显示在正文中正下方的部分区域之外。无法在 cms 中编辑它。如何在组件中声明正确的变量以链接到中继器项目?或者还有什么我忘记了?找不到任何关于我的问题的具体信息。

多次检查所有内容,并尝试了不同的语法和不同的输入类型

../site/blocks/competences.blade.php

@php
/** @var A17\Twill\Models\Behaviors\HasMedias $block */
@endphp
<div class="competences">
    <div class="l-container">
        <div class="competences-wrapper">
            <h1 class="competences-headline">{{ $block->translatedInput('headline') }}</h1>
            {!! $block->input('items') !!}
            </div>
        </div>
    </div>

../admin/blocks/competences.blade.php

@formField('input', [
    'name' => 'headline',
    'label' => 'Headline',
    'required' => true,
    'translated' => true
])

@formField('repeater', [
    'name' => 'items',
    'type' => 'competences_item'
])

twill.php

<?php

return [
    'block_editor' => [
        'blocks' => [
            'competences' => [
                'title' => 'Competences',
                'icon' => 'text',
                'component' => 'a17-block-competences'
                ]
        ],
        'repeaters' => [
            'competences_item' => [
                'title' => 'Competences Item',
                'trigger' => 'Add competence',
                'component' => 'a17-block-competences_item',
                'min' => 3,
                'max' => 3
            ]
        ],
    ]
];

应该显示在 section/div 内,但在它下方显示在 body 内,当然没有 CSS 样式

【问题讨论】:

    标签: php html laravel content-management-system twill


    【解决方案1】:
    Fixed it this way:
    
    @php
    /** @var A17\Twill\Models\Behaviors\HasMedias $block */
    @endphp
    <div class="competences">
        <div class="l-container">
            <div class="competences-wrapper">
                <h1 class="competences-headline">{{ $block->translatedInput('headline') }}</h1>
                @foreach ($block->children as $child)
                    @include('site.blocks.competences_item', ['child', $child])
                @endforeach
                </div>
            </div>
        </div>
    

    【讨论】:

      猜你喜欢
      • 2021-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-03
      • 1970-01-01
      • 1970-01-01
      • 2010-10-08
      相关资源
      最近更新 更多