Ein Foto gehoert zu keinem (ganzjaehrig) oder mehreren Erscheinungsbildern und erscheint nur dort, vor den ganzjaehrigen Fotos. Bausteine waehlen "automatisch" oder eine eigene Auswahl; Titelbereich und Abschluss zeigen das erste passende Foto ihrer Liste. Titelbild und "Bilder je Baustein" des Erscheinungsbilds werden in die Bausteine uebernommen und entfallen dort. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
2.0 KiB
PHP
57 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Themes\Sections;
|
|
|
|
use App\Themes\Theme;
|
|
use Filament\Forms\Components\RichEditor;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
|
|
/**
|
|
* Heading and text next to up to three photos, optionally with a link to another page.
|
|
*/
|
|
class TextImageSection extends Section
|
|
{
|
|
public static function key(): string
|
|
{
|
|
return 'text_image';
|
|
}
|
|
|
|
public static function label(): string
|
|
{
|
|
return 'Text mit Bildern';
|
|
}
|
|
|
|
public static function icon(): string
|
|
{
|
|
return 'heroicon-o-document-text';
|
|
}
|
|
|
|
public static function schema(): array
|
|
{
|
|
return [
|
|
TextInput::make('eyebrow')->label('Kleine Überschrift')->maxLength(100),
|
|
TextInput::make('heading')->label('Überschrift')->required()->maxLength(160),
|
|
RichEditor::make('text')->label('Text')->toolbarButtons([['bold', 'italic', 'link'], ['bulletList', 'orderedList']]),
|
|
static::photoSelect('photo_ids', 'Bilder', multiple: true)->maxItems(9)
|
|
->helperText('Gezeigt werden die ersten drei, die zum Erscheinungsbild passen. '.self::SEASON_HINT),
|
|
Select::make('image_position')->label('Bilder')->options(['right' => 'rechts', 'left' => 'links'])->default('right'),
|
|
TextInput::make('link_label')->label('Link-Text')->maxLength(80),
|
|
static::pageSelect('link_page', 'Link zur Seite'),
|
|
];
|
|
}
|
|
|
|
public function data(Theme $theme, array $data): array
|
|
{
|
|
return [
|
|
'eyebrow' => $data['eyebrow'] ?? null,
|
|
'heading' => $data['heading'] ?? '',
|
|
'text' => $this->html($data['text'] ?? null),
|
|
'photos' => $this->chosenPhotos($theme, $data['photo_ids'] ?? [])->take(3)->values(),
|
|
'imagePosition' => $data['image_position'] ?? 'right',
|
|
'linkLabel' => $data['link_label'] ?? null,
|
|
'linkUrl' => $this->pageUrl($data['link_page'] ?? null),
|
|
];
|
|
}
|
|
}
|