I frequently utilize Container Content Elements in TYPO3 for versatile content management. The setup is straightforward, but I would like the label of the container to show by default after its addition in the backend, eliminating the need to manually input a title. This would clarify the type of container being used. Currently, without a designated title, the container appears empty. I would appreciate any suggestions on achieving this automatically.
SOLUTION (Credit to Julian):
To set a custom backend template when registering a container, use the method “setBackendTemplate” in the following file:
VENDOR/Module/Configuration/TCA/Overrides/tt_content.php
\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
'Description for the container', // description
[
// ...
] // grid configuration
))
->setBackendTemplate('EXT:Module/Resources/Private/Templates/Container/Example.html')
);
The contents for the backend template located in:
EXT:Module/Resources/Private/Templates/Container/Example.html
may look like this:
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:container="http://typo3.org/ns/B13/Container/ViewHelpers"
data-namespace-typo3-fluid="true"
>
## Displaying CType
Container: <strong>{CType}</strong><br>
## Using translation
<f:translate key="LLL:EXT:sitepackage_example/Resources/Private/Language/locallang.xlf:container.{CType}" />
<f:format.raw>{tx_container_grid}</f:format.raw>
</html>