From 0cab8cded9322d4c950822fd681592913d932d59 Mon Sep 17 00:00:00 2001 From: Nikita Hovratov <nikita.h@live.de> Date: Fri, 30 Apr 2021 22:07:56 +0200 Subject: [PATCH] [BUGFIX] Enable overriding header of backend preview again Since commit e09082f (v10 release) the possibility to override the preview header was gone. This patch moves the drawItem hook out of the renderPageModulePreviewContent method to be able to pass the before rendered previewHeader to it. Resolves: #91760 Relates: #90906 Releases: master Change-Id: Ia7d29333543d764f4ebaec0330df1817032dc8fe Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68953 Tested-by: Benni Mack <benni@typo3.org> Tested-by: core-ci <typo3@b13.com> Tested-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Oliver Bartsch <bo@cedev.de> --- .../StandardContentPreviewRenderer.php | 19 --------------- .../BackendLayout/Grid/GridColumnItem.php | 23 ++++++++++++++++++- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/typo3/sysext/backend/Classes/Preview/StandardContentPreviewRenderer.php b/typo3/sysext/backend/Classes/Preview/StandardContentPreviewRenderer.php index 507f55229887..bd2f9deedcf5 100644 --- a/typo3/sysext/backend/Classes/Preview/StandardContentPreviewRenderer.php +++ b/typo3/sysext/backend/Classes/Preview/StandardContentPreviewRenderer.php @@ -24,7 +24,6 @@ use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumnItem; use TYPO3\CMS\Backend\View\PageLayoutView; use TYPO3\CMS\Backend\View\PageLayoutViewDrawFooterHookInterface; -use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Imaging\Icon; @@ -103,24 +102,6 @@ class StandardContentPreviewRenderer implements PreviewRendererInterface, Logger $contentTypeLabels = $item->getContext()->getContentTypeLabels(); $languageService = $this->getLanguageService(); - $drawItem = true; - $hookPreviewContent = ''; - // Hook: Render an own preview of a record - if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'])) { - $pageLayoutView = PageLayoutView::createFromPageLayoutContext($item->getContext()); - foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'] ?? [] as $className) { - $hookObject = GeneralUtility::makeInstance($className); - if (!$hookObject instanceof PageLayoutViewDrawItemHookInterface) { - throw new \UnexpectedValueException($className . ' must implement interface ' . PageLayoutViewDrawItemHookInterface::class, 1582574553); - } - $hookObject->preProcess($pageLayoutView, $drawItem, $previewHeader, $hookPreviewContent, $record); - } - $item->setRecord($record); - } - - if (!$drawItem) { - return $hookPreviewContent; - } // Check if a Fluid-based preview template was defined for this CType // and render it via Fluid. Possible option: // mod.web_layout.tt_content.preview.media = EXT:site_mysite/Resources/Private/Templates/Preview/Media.html diff --git a/typo3/sysext/backend/Classes/View/BackendLayout/Grid/GridColumnItem.php b/typo3/sysext/backend/Classes/View/BackendLayout/Grid/GridColumnItem.php index 1ea438f31341..89878c6b9b30 100644 --- a/typo3/sysext/backend/Classes/View/BackendLayout/Grid/GridColumnItem.php +++ b/typo3/sysext/backend/Classes/View/BackendLayout/Grid/GridColumnItem.php @@ -21,6 +21,8 @@ use TYPO3\CMS\Backend\Preview\StandardPreviewRendererResolver; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\PageLayoutContext; +use TYPO3\CMS\Backend\View\PageLayoutView; +use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Site\Entity\SiteLanguage; use TYPO3\CMS\Core\Type\Bitmask\Permission; @@ -77,7 +79,26 @@ class GridColumnItem extends AbstractGridObject $this->context->getPageId() ); $previewHeader = $previewRenderer->renderPageModulePreviewHeader($this); - $previewContent = $previewRenderer->renderPageModulePreviewContent($this); + + $drawItem = true; + $previewContent = ''; + // Hook: Render an own preview of a record + if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'])) { + $pageLayoutView = PageLayoutView::createFromPageLayoutContext($this->getContext()); + foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'] ?? [] as $className) { + $hookObject = GeneralUtility::makeInstance($className); + if (!$hookObject instanceof PageLayoutViewDrawItemHookInterface) { + throw new \UnexpectedValueException($className . ' must implement interface ' . PageLayoutViewDrawItemHookInterface::class, 1582574553); + } + $hookObject->preProcess($pageLayoutView, $drawItem, $previewHeader, $previewContent, $record); + } + $this->setRecord($record); + } + + if ($drawItem) { + $previewContent = $previewRenderer->renderPageModulePreviewContent($this); + } + return $previewRenderer->wrapPageModulePreview($previewHeader, $previewContent, $this); } -- GitLab