From 1279334ed1a0cc07e373a74d3147a020ccc00552 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Wed, 8 Jan 2020 19:15:08 +0100 Subject: [PATCH] Use PageLayoutHeader hook instead of new PageLayoutView hook Do not overcomplicate the implementation. Just add page info to rendered page. --- .../PageLayoutHeader.php} | 41 +++++++------------ .../BackendLayouts/BlogPost.tsconfig | 14 ++----- ext_localconf.php | 6 +-- 3 files changed, 20 insertions(+), 41 deletions(-) rename Classes/Hooks/{View/PageLayoutView.php => Backend/PageLayoutHeader.php} (67%) diff --git a/Classes/Hooks/View/PageLayoutView.php b/Classes/Hooks/Backend/PageLayoutHeader.php similarity index 67% rename from Classes/Hooks/View/PageLayoutView.php rename to Classes/Hooks/Backend/PageLayoutHeader.php index 2e06c83..4cd9cbf 100644 --- a/Classes/Hooks/View/PageLayoutView.php +++ b/Classes/Hooks/Backend/PageLayoutHeader.php @@ -1,6 +1,6 @@ @@ -21,56 +21,43 @@ namespace DanielSiepmann\DsSite\Hooks\View; * 02110-1301, USA. */ -use TYPO3\CMS\Backend\View\PageLayoutView as Typo3PageLayoutView; +use TYPO3\CMS\Backend\Controller\PageLayoutController; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\CMS\Frontend\Resource\FileCollector; -/** - * Holds all TYPO3 Hooks for PageLayoutView class. - */ -class PageLayoutView +class PageLayoutHeader { /** - * @var Typo3PageLayoutView + * @var PageLayoutController */ - private $layoutView; + private $pageLayoutController; - public function processColPosGrid( - Typo3PageLayoutView $layoutView, - array $columnConfig + public function render( + array $params, + PageLayoutController $pageLayoutController ): string { - $this->layoutView = $layoutView; - if (isset($columnConfig['colPos']) && trim($columnConfig['colPos']) !== '') { - return ''; - } + $this->pageLayoutController = $pageLayoutController; - if (isset($columnConfig['name']) && $columnConfig['name'] === 'Meta Info') { - return $this->renderMetaInfo(); - } - } - - private function renderMetaInfo(): string - { $view = $this->getView(); $view->assignMultiple([ - 'record' => $this->layoutView->pageRecord, + 'record' => $this->pageLayoutController->pageinfo, 'metaInfo' => [ [ 'label' => 'introduction', - 'value' => $this->layoutView->pageRecord['abstract'], + 'value' => $this->pageLayoutController->pageinfo['abstract'], 'field' => 'abstract', 'type' => 'string', ], [ 'label' => 'published', - 'value' => $this->layoutView->pageRecord['lastUpdated'], + 'value' => $this->pageLayoutController->pageinfo['lastUpdated'], 'field' => 'lastUpdated', 'type' => 'date', ], [ 'label' => 'updated', - 'value' => $this->layoutView->pageRecord['SYS_LASTCHANGED'], + 'value' => $this->pageLayoutController->pageinfo['SYS_LASTCHANGED'], 'type' => 'date', ], [ @@ -93,7 +80,7 @@ class PageLayoutView private function resolvePageMedia(): array { - $page = ['uid' => $this->layoutView->pageRecord['uid']]; + $page = ['uid' => $this->pageLayoutController->pageinfo['uid']]; $files = new FileCollector(); $files->addFilesFromRelation('pages', 'media', $page); diff --git a/Configuration/PageTSconfig/Mod/WebLayout/BackendLayouts/BlogPost.tsconfig b/Configuration/PageTSconfig/Mod/WebLayout/BackendLayouts/BlogPost.tsconfig index 9876557..6121ed2 100644 --- a/Configuration/PageTSconfig/Mod/WebLayout/BackendLayouts/BlogPost.tsconfig +++ b/Configuration/PageTSconfig/Mod/WebLayout/BackendLayouts/BlogPost.tsconfig @@ -8,14 +8,6 @@ mod.web_layout.BackendLayouts { rowCount = 5 rows { 1 { - columns { - 1 { - name = Meta Info - colPos = - } - } - } - 2 { columns { 1 { name = Introduction @@ -23,7 +15,7 @@ mod.web_layout.BackendLayouts { } } } - 3 { + 2 { columns { 1 { name = Content @@ -31,7 +23,7 @@ mod.web_layout.BackendLayouts { } } } - 4 { + 3 { columns { 1 { name = Acknowledgements @@ -39,7 +31,7 @@ mod.web_layout.BackendLayouts { } } } - 5 { + 4 { columns { 1 { name = Further reading diff --git a/ext_localconf.php b/ext_localconf.php index b05afec..09c35d2 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -8,9 +8,9 @@ ], ], 'SC_OPTIONS' => [ - 'cms/layout/class.tx_cms_layout.php' => [ - 'colpos_content' => [ - $extKey => \DanielSiepmann\DsSite\Hooks\View\PageLayoutView::class, + 'cms/layout/db_layout.php' => [ + 'drawHeaderHook' => [ + $extKey => \DanielSiepmann\DsSite\Hooks\Backend\PageLayoutHeader::class . '->render', ], ], ],