Last active
March 18, 2020 20:25
-
-
Save mhuber84/dc54fb7a9cc041639dc9d9fc6716400d to your computer and use it in GitHub Desktop.
Show page's description (page.rowDescription) in the TYPO3 backend page module (based on EXT:sys_note)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook']['my_theme'] = | |
\MyVendor\MyTheme\Hook\PageRowDescriptionHook::class . '->render'; | |
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawFooterHook']['my_theme'] = | |
\MyVendor\MyTheme\Hook\PageRowDescriptionHook::class . '->render'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MyVendor\MyTheme\Hook; | |
use TYPO3\CMS\Core\Utility\GeneralUtility; | |
use TYPO3\CMS\Fluid\View\StandaloneView; | |
use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper; | |
class PageRowDescriptionHook | |
{ | |
/** | |
* Add page's rowDescription as additional content to the header and footer of the page module | |
* | |
* @param array $params | |
* @param \TYPO3\CMS\Backend\Controller\PageLayoutController $parentObject | |
* @return string | |
*/ | |
public function render(array $params = [], \TYPO3\CMS\Backend\Controller\PageLayoutController $parentObject) | |
{ | |
$page = $parentObject->pageinfo; | |
if ($page && $page['rowDescription']) { | |
$view = GeneralUtility::makeInstance(StandaloneView::class); | |
$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/InfoBox.html')); | |
$title = 'Page description'; | |
$message = '<p>' . nl2br(htmlspecialchars($page['rowDescription'])). '</p>'; | |
$view->assignMultiple([ | |
'title' => $title, | |
'message' => $message, | |
'state' => InfoboxViewHelper::STATE_INFO | |
]); | |
return $view->render(); | |
} | |
return ''; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment