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

2.0.2 2026-01-27 16:10 UTC

This package is auto-updated.

Last update: 2026-01-27 16:10:28 UTC


README

This bundle offers functionality for selecting custom palettes depending on the parent archive for the backend of the Contao CMS.

screenshot.png

Setup

  1. Install via composer: composer require heimrichhannot/contao-archive-palettes-bundle.
  2. 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.