vielen Dank.
Da hatte ich übrigends noch einen weiteren Fehler mit eingebaut ... ['palettes'] hatte gefehlt.
für Nachleser das Ergebnis:
PHP-Code:
<?php
use Contao\CoreBundle\DataContainer\PaletteManipulator;
use Contao\System;
PaletteManipulator::create()
->addField('sectionBackground', 'articleSpacingLegend', PaletteManipulator::POSITION_APPEND)
->applyToPalette('default', 'tl_article');
$GLOBALS['TL_DCA']['tl_article']['palettes']['__selector__'][] = 'sectionBackground';
$GLOBALS['TL_DCA']['tl_article']['subpalettes']['sectionBackground_addimage'] = 'background_addimage, background_size';
$GLOBALS['TL_DCA']['tl_article']['fields']['sectionBackground'] = [
'label' => &$GLOBALS['TL_LANG']['tl_article']['sectionBackground'],
'inputType' => 'select',
'options' => [
'addimage'
],
'reference' => &$GLOBALS['TL_LANG']['MSC']['optSectionBackground'],
'eval' => ['tl_class' => 'w50 clr', 'includeBlankOption' => true, 'chosen' => true, 'submitOnChange' => true],
'sql' => "varchar(255) NOT NULL default ''"
];
$GLOBALS['TL_DCA']['tl_article']['fields']['background_addimage'] = [
'label' => &$GLOBALS['TL_LANG']['tl_article']['background_addimage'],
'exclude' => true,
'inputType' => 'fileTree',
'eval' => [
'files' => true,
'filesOnly' => true,
'fieldType' => 'radio',
'extensions' => \Contao\Config::get('validImageTypes'),
'tl_class' => 'clr',
],
'sql' => ['type' => 'binary', 'length' => 16, 'notnull' => false],
];
$GLOBALS['TL_DCA']['tl_article']['fields']['background_size'] = [
'label' => &$GLOBALS['TL_LANG']['tl_article']['background_size'],
'exclude' => true,
'inputType' => 'imageSize',
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => ['rgxp' => 'natural', 'includeBlankOption' => true, 'nospace' => true, 'helpwizard' => true, 'tl_class' => 'w50'],
'options_callback' => function () {
return System::getContainer()->get('contao.image.image_sizes')->getOptionsForUser(BackendUser::getInstance());
},
'sql' => "varchar(64) NOT NULL default ''",
];
ich füge hier zusätzlich zur Auswahl der Quelldatei auch noch die Bildgrösse mit ein.
Lesezeichen