heimrichhannot / contao-archive-palettes-bundle
This bundle offers functionality for selecting custom palettes depending on the parent archive for the backend of the Contao CMS.
Installs: 1 375
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:contao-bundle
pkg:composer/heimrichhannot/contao-archive-palettes-bundle
Requires
- php: ^8.2
- contao/core-bundle: ^5.3
- heimrichhannot/contao-utils-bundle: ^3.10
- symfony/dependency-injection: ^6.4 || ^7.0
- symfony/translation-contracts: ^1.0 || ^2.0 || ^3.0
Requires (Dev)
- contao/contao-rector: dev-main
- contao/manager-plugin: ^2.13
- phpstan/phpstan: ^2.1
- phpstan/phpstan-symfony: ^2.0
- rector/rector: ^2.3
- symplify/easy-coding-standard: ^13.0
README
This bundle offers functionality for selecting custom palettes depending on the parent archive for the backend of the Contao CMS.
Setup
- Install via composer:
composer require heimrichhannot/contao-archive-palettes-bundle. - Adjust your dca fields:
Parent table (e.g. tl_news_archive):
// contao/dca/tl_news_archive.php <?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');
Child table (e.g. tl_news):
// contao/dca/tl_news.php <?php use HeimrichHannot\ArchivePalettesBundle\Dca\ArchivePaletteChild; ArchivePaletteChild::register('tl_news', 'tl_news_archive');
Customization
You can customize the checkbox and selector field:
// contao/dca/tl_news_archive.php <?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');
Upgrade from version 1
The bundle was completely rewritten for version 2. For upgrade you need to adjust your dca files as described in the setup. The old configuration or manager implementation will not work anymore.
