tl_content Feld hinzufügen via DCA u. Palette Manipulator
Hallo,
ich versuche ein neues Feld zu erstellen über die Datei "contao/dca/tl_content.php":
PHP-Code:
<?php
// contao/dca/tl_content.php
use Contao\CoreBundle\DataContainer\PaletteManipulator;
/*
foreach ($GLOBALS['TL_DCA']['tl_content']['palettes'] as $k => $palette)
{
if (!is_array($palette) && strpos($palette, "cssID") !== false)
{
$GLOBALS['TL_DCA']['tl_content']['palettes'][$k] = str_replace
(
'{expert_legend',
'{Meine Legende}, yDataAttributes;{expert_legend',
$GLOBALS['TL_DCA']['tl_content']['palettes'][$k]
);
}
}
*/
$GLOBALS['TL_DCA']['tl_content']['fields']['yDataAttributes'] = [
'label' => ['Data-Attribut', 'Hier können Sie Data-Attribute vergeben.'],
'inputType' => 'text',
'eval' => ['tl_class' => 'w50', 'maxlength' => 255],
'sql' => ['type' => 'string', 'length' => 255, 'default' => ''],
];
PaletteManipulator::create()
// add a new "custom_legend" before the "expert_legend"
->addLegend('Meine Legende Demo', 'expert_legend', PaletteManipulator::POSITION_BEFORE)
// directly add new fields to the new legend
->addField('yDataAttributes', 'Meine Legende Demo', PaletteManipulator::POSITION_APPEND)
// then apply it to the palette as usual
->applyToPalette('default', 'tl_content')
;
?>
Soweit funktioniert es wenn ich eine neue Legende über die foreach Schleife hinzufüge (o. auskommentiert).
Beim Versuch dies über den Palette Manipulator zu realisieren wird mir im Backend dann aber nichts angezeigt?
Für Hilfe dankbar.
Franko