
Zitat von
esc
Ich weiß bescheid wie ich zusätzliche Felder einfügen kann aber einfach nur einen Text ohne irgendein Eingabefeld - das schaff ich nicht.
Von Haus aus geht das nicht. Du könntest aber https://github.com/heimrichhannot/co...anation-bundle nutzen - erfordert aber zusätzliche Programmierung. z.B.:
PHP-Code:
// contao/dca/tl_content.php
$GLOBALS['TL_DCA']['tl_content']['fields']['explanation'] = [
'inputType' => 'explanation',
'eval' => [
'text_callback' => static function (array $attributes): string {
/** @var TranslatorInterface $translator */
$translator = System::getContainer()->get('translator');
$type = $attributes['dataContainer']?->activeRecord->type ?? null;
return $translator->trans('CTE.'.$type.'.1', [], 'contao_default');
},
'class' => 'tl_info',
'tl_class' => 'clr long',
],
];
PHP-Code:
// src/EventListener/DataContainer/ContentPaletteCallback.php
namespace App\EventListener\DataContainer;
use Contao\CoreBundle\DataContainer\PaletteManipulator;
use Contao\CoreBundle\DependencyInjection\Attribute\AsCallback;
#[AsCallback(table: 'tl_content', target: 'config.onpalette')]
class ContentPaletteCallback
{
public function __invoke(string $palette): string
{
PaletteManipulator::create()
->addField('explanation', 'type')
->applyToString($palette)
;
return $palette;
}
}
(ungetestet)