PHP code example of heimrichhannot / contao-archive-palettes-bundle
1. Go to this page and download the library: Download heimrichhannot/contao-archive-palettes-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
heimrichhannot / contao-archive-palettes-bundle example snippets
// contao/dca/tl_news_archive.php
use Contao\CoreBundle\DataContainer\PaletteManipulator;
use HeimrichHannot\ArchivePalettesBundle\Dca\ArchivePaletteFields;
ArchivePaletteFields::register('tl_news_archive', 'tl_news');
PaletteManipulator::create()
->addLegend(ArchivePaletteFields::DEFAULT_PALETTE_NAME, 'title_legend')
->addField(ArchivePaletteFields::DEFAULT_CHECKBOX_FIELD, ArchivePaletteFields::DEFAULT_PALETTE_NAME, PaletteManipulator::POSITION_APPEND)
->applyToPalette('default', 'tl_news_archive');
// contao/dca/tl_news.php
use HeimrichHannot\ArchivePalettesBundle\Dca\ArchivePaletteChild;
ArchivePaletteChild::register('tl_news', 'tl_news_archive');
// contao/dca/tl_news_archive.php
use Contao\CoreBundle\DataContainer\PaletteManipulator;
use HeimrichHannot\ArchivePalettesBundle\Dca\ArchivePaletteFields;
use HeimrichHannot\ArchivePalettesBundle\Dca\FieldConfiguration;
ArchivePaletteFields::register('tl_news_archive', 'tl_news')
->configureCheckboxField(function (FieldConfiguration $fieldConfiguration) {
$fieldConfiguration
->setFieldName('addCustomNewsPalettes')
->setFilter(true)
->setExclude(false)
->setEvalValue('tl_class', 'w50 m12')
;
})
->configureSelectorField(function (FieldConfiguration $fieldConfiguration) {
$fieldConfiguration
->setFieldName('customNewsPalettes')
->setSearch(true)
;
});
PaletteManipulator::create()
->addLegend('palettes_legend', 'protected_legend', PaletteManipulator::POSITION_AFTER)
->addField('addCustomNewsPalettes', 'palettes_legend', PaletteManipulator::POSITION_APPEND)
->applyToPalette('default', 'tl_news_archive');