Sorry, ich schon wieder.
Habe das Feld jetzt als "keyValueWizard" angelegt:
PHP-Code:
<?php
// contao/dca/tl_content.php
use Contao\CoreBundle\DataContainer\PaletteManipulator;
$GLOBALS['TL_DCA']['tl_content']['fields']['myCustomDataAttributes'] = [
'label' => ['Data-Attribut', 'Hier können Sie Data-Attribute vergeben.'],
'inputType' => 'keyValueWizard',
'eval' => ['tl_class' => 'w50'],
'exclude' => true,
'sql' => "text NULL",
];
foreach ($GLOBALS['TL_DCA']['tl_content']['palettes'] as $name => $palette) {
if (!\is_string($palette)) {
continue;
}
PaletteManipulator::create()
// add a new Legend before the "expert_legend"
->addLegend('Einstellungen Data-Attribute', 'expert_legend', PaletteManipulator::POSITION_AFTER)
// directly add new field(s)s to the new legend
->addField('myCustomDataAttributes', 'Einstellungen Data-Attribute', PaletteManipulator::POSITION_APPEND)
// then apply it to the palette as usual
->applyToPalette($name, 'tl_content')
;
}
Wie kann ich die Eingaben jetzt im Template "block_searchable.html5" zur Anzeige bringen?
Bekomme mit:
PHP-Code:
<?php if ($this->myCustomDataAttributes): ?> <?= $this->myCustomDataAttributes ?><?php endif; ?>
jetzt z.B.:
HTML-Code:
<div class="ce_text block" a:2:{i:0;a:2:{s:3:"key";s:8:"dat_demo";s:5:"value";s:1:"1";}i:1;a:2:{s:3:"key";s:9:"dat_demo2";s:5:"value";s:1:"2";}}="">
..
</div>
Lesezeichen