From 3b6337cdcd6fe1f538b5310eeb2d2618aa79452c Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Thu, 6 Aug 2026 15:49:15 +0200 Subject: [PATCH] [FEATURE] Allow disabling the container backend template setBackendTemplate() now accepts null, and disableBackendTemplate() is a shortcut for it. When disabled, Registry no longer registers mod.web_layout.tt_content.preview. PageTSconfig for that CType, so another preview mechanism (e.g. b13/backendpreviews) can take over instead of the built-in backend template. --- Classes/Tca/ContainerConfiguration.php | 12 +++++++++--- Classes/Tca/Registry.php | 4 +++- README.md | 3 ++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Classes/Tca/ContainerConfiguration.php b/Classes/Tca/ContainerConfiguration.php index d62f4909..b6337ca9 100644 --- a/Classes/Tca/ContainerConfiguration.php +++ b/Classes/Tca/ContainerConfiguration.php @@ -19,7 +19,7 @@ class ContainerConfiguration protected string $description = ''; protected array $grid = []; protected string $icon = 'EXT:container/Resources/Public/Icons/Extension.svg'; - protected string $backendTemplate = 'EXT:container/Resources/Private/Templates/Container.html'; + protected ?string $backendTemplate = 'EXT:container/Resources/Private/Templates/Container.html'; protected string $gridTemplate = 'EXT:container/Resources/Private/Templates/Grid.html'; protected array $gridPartialPaths = [ 'EXT:backend/Resources/Private/Partials/', @@ -51,7 +51,7 @@ public function setIcon(string $icon): ContainerConfiguration return $this; } - public function setBackendTemplate(string $backendTemplate): ContainerConfiguration + public function setBackendTemplate(?string $backendTemplate): ContainerConfiguration { $this->backendTemplate = $backendTemplate; return $this; @@ -147,11 +147,17 @@ public function getIcon(): string return $this->icon; } - public function getBackendTemplate(): string + public function getBackendTemplate(): ?string { return $this->backendTemplate; } + public function disableBackendTemplate(): ContainerConfiguration + { + $this->backendTemplate = null; + return $this; + } + public function isRegisterInNewContentElementWizard(): bool { return $this->registerInNewContentElementWizard; diff --git a/Classes/Tca/Registry.php b/Classes/Tca/Registry.php index 439d5a7a..71faf0cf 100644 --- a/Classes/Tca/Registry.php +++ b/Classes/Tca/Registry.php @@ -283,10 +283,12 @@ public function getPageTsString(): string $defaultGroup = 'container'; $cTypesExcludedInNewContentElementWizard = []; foreach ($GLOBALS['TCA']['tt_content']['containerConfiguration'] as $cType => $containerConfiguration) { - $pageTs .= chr(10) . 'mod.web_layout.tt_content.preview { + if ($containerConfiguration['backendTemplate'] !== null) { + $pageTs .= chr(10) . 'mod.web_layout.tt_content.preview { ' . $cType . ' = ' . $containerConfiguration['backendTemplate'] . ' } '; + } // s. https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/13.0/Breaking-102834-RemoveItemsFromNewContentElementWizard.html if ($containerConfiguration['registerInNewContentElementWizard'] === false) { $group = $containerConfiguration['group'] !== '' ? $containerConfiguration['group'] : $defaultGroup; diff --git a/README.md b/README.md index 35a4e6cf..33b4fcc6 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,8 @@ This is an example of creating a two-column container. The code snippet goes int | Method name | Description | Parameters | Default | | ----------- | ----------- | ---------- | ---------- | | `setIcon` | icon file, or existing icon identifier | `string $icon` | `'EXT:container/Resources/Public/Icons/Extension.svg'` | -| `setBackendTemplate` | Template for backend view| `string $backendTemplate` | `EXT:container/Resources/Private/Templates/Container.html'` | +| `setBackendTemplate` | Template for backend view| `?string $backendTemplate` | `EXT:container/Resources/Private/Templates/Container.html'` | +| `disableBackendTemplate` | Disables the backend template for this CType (shortcut for `setBackendTemplate(null)`), if you want another preview mechanism (e.g. EXT:backenlayout) | - | - | | `setGridTemplate` | Template for grid | `string $gridTemplate` | `'EXT:container/Resources/Private/Templates/Grid.html'` | | `setGridPartialPaths` / `addGridPartialPath` | Partial root paths for grid | `array $gridPartialPaths` / `string $gridPartialPath` | `['EXT:backend/Resources/Private/Partials/', 'EXT:container/Resources/Private/Partials/']` | | `setGridLayoutPaths` | Layout root paths for grid | `array $gridLayoutPaths` | `[]` |