Examples

The TCA of the styleguide extension provides palettes with different properties.

Examples of different palettes in the extension styleguide

Palettes get defined in the section palettes of the tables TCA array.

The following TCA section specifies the different palettes.

EXT:styleguide/Configuration/TCA/tx_styleguide_palette.php
[
    'palettes' => [
        'palette_1' => [
            'label' => 'palette_1',
            'description' => 'palette description',
            'showitem' => 'palette_1_1, palette_1_3',
        ],
        'palette_2' => [
            'showitem' => 'palette_2_1',
        ],
        'palette_3' => [
            'showitem' => 'palette_3_1, palette_3_2',
        ],
        'palette_4' => [
            'showitem' => 'palette_4_1, palette_4_2, palette_4_3, --linebreak--, palette_4_4',
        ],
        'palette_5' => [
            'showitem' => 'palette_5_1, --linebreak--, palette_5_2',
        ],
        'palette_6' => [
            'showitem' => 'palette_6_1',
            'isHiddenPalette' => true,
        ],
        'palette_7' => [
            'showitem' => 'palette_7_1',
        ],
    ],
]
Copied!

The palettes then get referenced in the types section:

EXT:styleguide/Configuration/TCA/tx_styleguide_palette.php
[
    'types' => [
        [
            'showitem' => '
                --div--;palette,
                    --palette--;;palette_1,
                    --palette--;palette_2;palette_2,
                    --palette--;palette_3;palette_3,
                    --palette--;;palette_4,
                    --palette--;palette_5;palette_5,
                --div--;hidden palette,
                    --palette--;palette_6;palette_6,
                    --palette--;palette_7 (palette_6 hidden);palette_7,
            ',
        ],
    ],
]
Copied!

It is also possible to define the label of a palette directly in the palette definition. Declaring the label in an 'palettes' array can reduce boilerplate declarations if a palette is used over and over again in multiple types. If a label is defined for a palette this way, it is always displayed. Setting a specific label in the 'types' array for a palette overrides the default label that was defined within the 'palettes' array. There is no way to unset a label that is set within the 'palettes' array. It will always be displayed.

Example:

'types' => [
   'myType' => [
      'showitem' => 'aField, --palette--;;aPalette, someOtherField',
   ],
],
'palettes' => [
   'aPalette' => [
      'label' => 'LLL:EXT:myExt/Resources/Private/Language/locallang.xlf:aPaletteDescription',
      'showitem' => 'aFieldInAPalette, anotherFieldInPalette',
   ],
],
Copied!