getRecord(); $context = $event->getPageLayoutContext(); $fluidTemplateFile = BackendUtility::getPagesTSconfig($record->getPid())['mod.']['web_layout.'][$event->getTable() . '.']['preview.'][$event->getRecordType()] ?? ''; if ($fluidTemplateFile === '') { return; } $fluidTemplateFileAbsolutePath = GeneralUtility::getFileAbsFileName($fluidTemplateFile); if ($fluidTemplateFileAbsolutePath === '') { return; } try { $event->setPreviewContent( $this->viewFactory ->create(new ViewFactoryData(templatePathAndFilename: $fluidTemplateFileAbsolutePath, request: $context->getCurrentRequest())) ->assign('record', $record) ->render() ); } catch (\Exception $e) { $this->logger->warning('The backend preview for content element {uid} can not be rendered using the Fluid template file "{file}"', [ 'uid' => $record->getUid(), 'file' => $fluidTemplateFileAbsolutePath, 'exception' => $e, ]); if ($this->getBackendUser()->shallDisplayDebugInformation()) { $event->setPreviewContent( $this->viewFactory ->create(new ViewFactoryData(templatePathAndFilename: 'EXT:backend/Resources/Private/Templates/PageLayout/FluidBasedContentPreviewRenderingException.fluid.html')) ->assign('error', [ 'message' => str_replace(Environment::getProjectPath(), '', $e->getMessage()), 'title' => 'Error while rendering FluidTemplate preview using ' . str_replace(Environment::getProjectPath(), '', $fluidTemplateFileAbsolutePath), ]) ->render() ); } } } private function getBackendUser(): BackendUserAuthentication { return $GLOBALS['BE_USER']; } }