diff --git a/Classes/Listener/PageContentPreviewRendering.php b/Classes/Listener/PageContentPreviewRendering.php new file mode 100644 index 00000000..e986e24a --- /dev/null +++ b/Classes/Listener/PageContentPreviewRendering.php @@ -0,0 +1,39 @@ +gridRenderer = $gridRenderer; + $this->tcaRegistry = $tcaRegistry; + } + + public function __invoke(PageContentPreviewRenderingEvent $event): void + { + $record = $event->getRecord(); + if (!$this->tcaRegistry->isContainerElement($record['CType'])) { + return; + } + $record['tx_container_grid'] = $this->gridRenderer->renderGrid($record, $event->getPageLayoutContext()); + $event->setRecord($record); + } +} diff --git a/Classes/Tca/Registry.php b/Classes/Tca/Registry.php index 1f41df6e..70ea4e3b 100644 --- a/Classes/Tca/Registry.php +++ b/Classes/Tca/Registry.php @@ -66,7 +66,9 @@ public function configureContainer(ContainerConfiguration $containerConfiguratio ); } - $GLOBALS['TCA']['tt_content']['types'][$containerConfiguration->getCType()]['previewRenderer'] = \B13\Container\Backend\Preview\ContainerPreviewRenderer::class; + if ($containerConfiguration->getBackendTemplate() === null || (GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 11) { + $GLOBALS['TCA']['tt_content']['types'][$containerConfiguration->getCType()]['previewRenderer'] = \B13\Container\Backend\Preview\ContainerPreviewRenderer::class; + } if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 13) { if (!isset($GLOBALS['TCA']['tt_content']['types'][$containerConfiguration->getCType()]['creationOptions'])) { diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index ee4ba369..ee77691d 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -68,6 +68,11 @@ services: tags: - name: event.listener identifier: 'tx-container-boot-completed' + B13\Container\Listener\PageContentPreviewRendering: + tags: + - name: event.listener + identifier: 'tx-container-page-content-preview-rendering' + before: 'typo3-backend/fluid-preview/content' B13\Container\Command\FixLanguageModeCommand: tags: - name: 'console.command'