Container wrap 

Extension key

container_wrap

Package name

traw/container-wrap

Version

1.1

Language

en

Author

Thomas Rawiel

License

This document is published under the Creative Commons BY 4.0 license.

Rendered

Wed, 14 Jan 2026 10:11:36 +0000


A collection of functions that wrap around EXT:container's Container registry, which make it easier to adjust/ change the registered container's TCA.


What does it do? 

EXT:container let's you create nested content elements ("containers") in a very simple way.

See EXT:container's Documentation

However, if you want to add TYPO3's default fields like header, subheader, header_link, assets etc. to your container, you have to configure the corresponding TCA in your own distribution extension.

This extension provides functions that aim to make this step easier and more straight-forward.


Installation 

Install EXT:container_wrap

How to use 

Register containers, add additional fields, change allowed fields

For any feedback, suggestions or anything else regarding this extension, please use the Github issue tracker

Installation 

Install this extension via composer:

composer require traw/container-wrap
Copied!

or add it to your extension's composer.json file:

"require": {
    "typo3/cms-core": "^12 || ^13",
    "traw/container-wrap": "^2.0"
}
Copied!

No additional configuration needed.

If you wish to allow/disallow CTypes in your container columns, it is recommended to install EXT:content_defender

"require": {
"typo3/cms-core": "^12 || ^13", "traw/container-wrap": "^2.0", "ichhabrecht/content-defender": "^3.4"

}

Note: Currently, there's no version for TYPO3 13

Register Containers 

Register containers with EXT:container alone 

With EXT:container you would typically go ahead and register each container seperately or in a foreach loop if you want to register multiple containers, e.g.

\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\B13\Container\Tca\Registry::class)->configureContainer(
    (
        new \B13\Container\Tca\ContainerConfiguration(
            'b13-2cols-with-header-container', // CType
            '2 Column Container With Header', // label
            'Some Description of the Container', // description
            [
                [
                    ['name' => 'header', 'colPos' => 200, 'colspan' => 2, 'allowed' => ['CType' => 'header, textmedia, b13-2cols']]
                ],
                [
                    ['name' => 'left side', 'colPos' => 201],
                    ['name' => 'right side', 'colPos' => 202, 'maxitems' => 1]
                ]
            ] // grid configuration
        )
    )
    // override default configurations
    ->setIcon('EXT:container_example/Resources/Public/Icons/b13-2cols-with-header-container.svg')
    ->setSaveAndCloseInNewContentElementWizard(false)
);
Copied!

(taken from EXT:container_example)

Then you would need to add your fields manually via $GLOBALS['TCA']['tt_content'] or functions like addTcaColumns, addFieldsToPalette, etc. from TYPO3s ExtensionManagementUtility and maybe manipulate the showitem config of your content element.

Register containers with EXT:container-wrap 

In your Configuration/TCA/Overrides/tt_content.php create an array with your container configurations:

$containers = [
  'b13-2cols-with-header-container' => [ //CType
      'label' => '2 Column Container With Header', //label
      'description' => 'Some Description of the Container', //description
      'columnConfiguration' => [
          [
              ['name' => 'header', 'colPos' => 200, 'colspan' => 2, 'allowed' => ['CType' => 'header, textmedia, b13-2cols']]
          ],
          [
              ['name' => 'left side', 'colPos' => 201],
              ['name' => 'right side', 'colPos' => 202, 'maxitems' => 1]
          ]
      ], //grid configuration
      //optional keys:
      'icon' => 'EXT:container/Resources/Public/Icons/container-1col.svg',
      'backendTemplate'=>'EXT:lin_container/Resources/Private/Templates/Backend/Container.html',
      'gridTemplate' => 'EXT:container/Resources/Private/Templates/Grid.html',
      'registerInNewContentElementWizard' => true,
      'saveAndCloseInNewContentElementWizard' => true,
      'group' => 'my-container-group', //CType select item group
      'header' => true,
      'bodytext' => false,
      'media' => false,
      'settings' => true,
      'flexform' => false,
  ],
  'my-container-2' => [
      // ...
      // config for my-container-2
      // ...
  ]
];
Copied!

and call the register function

\TRAW\ContainerWrap\Configuration\Container::registerContainers($containers);
Copied!

Configuration options 

When registering a container you have the following options:

Required 

CType

CType
type

string

Path

$config['your-ctype']

The CType used to identify your container

label

label
type

string

Path

$config['your-ctype']['label']

The label of your container

description

description
type

string

Path

$config['your-ctype']['description']

The description of your container, will be displayed for example in the content element wizard

columnConfiguration

columnConfiguration
type

array

Default

EXT:container/Resources/Public/Icons/Extension.svg

Path

$config['your-ctype']['columnConfiguration']

The configuration for your containers columns

See: https://github.com/b13/container?tab=readme-ov-file#adding-your-own-container-element

Optional 

Also see https://github.com/b13/container?tab=readme-ov-file#methods-of-the-containerconfiguration-object

icon

icon
type

string

Default

EXT:container/Resources/Public/Icons/Extension.svg

Path

$config['your-ctype']['icon']

An icon file, or existing icon identifier representing your container

backendTemplate

backendTemplate
type

string

Default

EXT:container/Resources/Private/Templates/Container.html

Path

$config['your-ctype']['backendTemplate']

The Fluid template used for the backend view

gridTemplate

gridTemplate
type

string

Default

EXT:container/Resources/Private/Templates/Grid.html

Path

$config['your-ctype']['gridTemplate']

Template for grid

registerInNewContentElementWizard

registerInNewContentElementWizard
type

boolean

Default

true

Path

$config['your-ctype']['registerInNewContentElementWizard']

Template for grid

saveAndCloseInNewContentElementWizard

saveAndCloseInNewContentElementWizard
type

boolean

Default

true

Path

$config['your-ctype']['saveAndCloseInNewContentElementWizard']

Template for grid

group

group
type

string

Default

container

Path

$config['your-ctype']['group']

CType select item group

The default value can be changed to $_EXTKEY.'_container' (myext_container) if you call the register function with the optional parameter

Enable tt-content fields 

header

header
type

boolean

Default

false

Path

$config['your-ctype']['header']

  • if true, will add the full headers palette (header, subheader, header_link,etc.)
  • if false, will only add the header field

bodytext

bodytext
type

boolean

Default

false

Path

$config['your-ctype']['bodytext']

if true, will add the bodytext field with richtext enabled

media

media
type

boolean

Default

false

Path

$config['your-ctype']['media']

If true will add the media --div-- with the assets field

settings

settings
type

boolean

Default

false

Path

$config['your-ctype']['settings']

If true, will add an empty palette containerSettings in a new --div-- "Container" If you configure custom fields for containers you could add them here, e.g. with ExtensionManagementUtility::addFieldsToPalette('tt_content', 'containerSettings', 'tx_yourfield')

flexform

flexform
type

string|boolean

Default

false

Path

$config['your-ctype']['flexform']

If _not_ false, the palette containerFlexform will be added to the Container --div--, which contains the pi_flexform field

If it contains a FILE string to a flexform xml, this will be added with ExtensionManagementUtility::addPiFlexFormValue() for this CType

Example: 'flexform' => 'FILE:EXT:my_ext/Configuration/Flexforms/MyContainerSettings.xml',

additionalFields

additionalFields
type

boolean

Default

false

Path

$config['your-ctype']['additionalFields']

If true, will add an empty palette containerAdditionalFields to the Extended tab If you configure custom fields for containers you could add them here, e.g. with ExtensionManagementUtility::addFieldsToPalette('tt_content', 'containerAdditionalFields', 'tx_yourfield')

columnsOverrides

columnsOverrides
type

array

Default

false

Path

$config['your-ctype']['columnsOverrides']

Changed or added ['columns'] field display definitions. See columnsOverrides

Additional fields 

Additional tt_content fields can be added to your container by using the additional fields config when registering containers

In the scenario where you want to enable or disable additional fields after you have registered the containers, e.g. in a theme extension, simply call the corresponding functions

Enable fields for one container 

setupShowItemForContainer(string $cType, array $configuration)

setupShowItemForContainer(string $cType, array $configuration)
CType

The container CType to change

configuration

An array containing the additional fields that should be changed

//Enable header, media and bodytext fields for `b13-2cols-with-header-container`
\TRAW\ContainerWrap\Configuration\Container::setupShowItemForContainer(
    'b13-2cols-with-header-container',
    [
        'header' => true,
        'media' => true,
        'bodytext' => true,
    ]
);
Copied!

Enable fields for multiple containers 

setupShowItemForContainers(array $containerCTypes, array $configuration): void

setupShowItemForContainers(array $containerCTypes, array $configuration): void
containerCTypes

An array containing the CTypes of containers

configuration

An array containing the additional fields that should be changed

//Enable the header palette for these 3 containers
\TRAW\ContainerWrap\Configuration\Container::setupShowItemForContainers(
    [
        'my-container-1',
        'my-container-2',
        'my-container-3',
    ],
    [
        'header' => true,
    ]
);
Copied!

Enable fields for all containers 

setupShowItemForAllContainers(array $configuration, array $exceptions = [])

setupShowItemForAllContainers(array $configuration, array $exceptions = [])
configuration

An array containing the additional fields that should be changed

exceptions

(Optional) An array containing container CTypes where the change should NOT be applied

//Enable the bodytext field for all containers, except these 2 containers
\TRAW\ContainerWrap\Configuration\Container::setupShowItemForAllContainers(
    [
        'bodytext' => true,
    ],
    [
        'my-container-3',
        'my-container-4'
    ]
);
Copied!

Allow / Disallow CTypes 

This requires the extension ichhabrecht/content-defender to be installed.

It is possible to allow and disallow CTypes when registering your container configurations, as well as set a maxitems

See Content Defender README

Typically you would want to set these in your initial columnConfiguration (see Register containers with EXT:container-wrap)

'columnConfiguration' => [
    [
        [
            'name' => 'Content',
            'colPos' => 100,
            'allowed' => [
                'CType' => 'textmedia',
            ],
        ],
    ],
]
Copied!
'columnConfiguration' => [
    [
        [
            'name' => 'Sidebar',
            'colPos' => 100,
            'disallowed' => [
                'CType' => 'list',
            ],
        ],
    ],
]
Copied!

In the scenario where you want to allow or disallow CTypes after you have registered the containers, e.g. in a theme extension, simply call the corresponding functions

allowInAllContainers(array $cTypes, array $exceptions = [])

allowInAllContainers(array $cTypes, array $exceptions = [])
cTypes

an array of CTypes that should be (additionally) allowed in all containers

exceptions

(Optional) an array of container CTypes where this change should NOT be applied

The given CTypes are added to the allowed CTypes of all containers.

allowInSpecificContainers(array $cTypes, array $allowInContainers, array $allowInColumns = [])

allowInSpecificContainers(array $cTypes, array $allowInContainers, array $allowInColumns = [])
cTypes

an array of CTypes that should be (additionally) allowed in all containers

allowInContainers

an array of container CTypes, where this change should be applied

allowInColumns

(Optional) an array of columns where this change should be applied, if omitted the change will be applied to all columns of the container

The given CTypes are added to the allowed CTypes of the given containers

allowInAllContainers(array $cTypes, array $exceptions = [])

allowInAllContainers(array $cTypes, array $exceptions = [])
cTypes

an array of CTypes that should be (additionally) allowed in all containers

exceptions

(Optional) an array of container CTypes where this change should NOT be applied

The given CTypes are added to the allowed CTypes of all containers.

disallowInSpecificContainers(array $cTypes, array $disallowInContainers, array $disallowInColumns = [])

disallowInSpecificContainers(array $cTypes, array $disallowInContainers, array $disallowInColumns = [])
cTypes

an array of CTypes that should be (additionally) allowed in all containers

allowInContainers

an array of container CTypes, where this change should be applied

allowInColumns

(Optional) an array of columns where this change should be applied, if omitted the change will be applied to all columns of the container

The given CTypes are added to the allowed CTypes of the given containers

//disallow any list-plugin in all containers
\TRAW\ContainerWrap\Configuration\Container::disallowInAllContainers(['list']);

//disallow image CType in my-container-1 and my-containr-2 if the colPos is 101 or 102
\TRAW\ContainerWrap\Configuration\Container::disallowInSpecificContainers(
    ['image'],
    ['my-container-1', 'my-container-2'],
    [101, 102]
);

//allow textmedia CType in all containers, except my-container-1
\TRAW\ContainerWrap\Configuration\Container::allowInAllContainers(['textmedia'], ['my-container-1']);
Copied!

Sitemap