Skip to content

Commit

Permalink
[FEATURE] Implement Top/Bottom rendering of sys_notes from TYPO3 v9LTS
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Opitz committed Apr 11, 2019
1 parent 547e497 commit fe40edb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
47 changes: 42 additions & 5 deletions Classes/Hooks/RenderHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,54 @@
*/
class RenderHook
{
/**
* Render inside Footer
*
* @var array $params
* @var BackendLayoutController $parentObject The TV+ BackendLayoutController
*/
public function renderHeaderFunctionHook(array $params, BackendLayoutController $parentObject)
{
/** @var $noteBootstrap \TYPO3\CMS\SysNote\Core\Bootstrap */
$noteBootstrap = GeneralUtility::makeInstance(\TYPO3\CMS\SysNote\Core\Bootstrap::class);
$content = $noteBootstrap->run('Note', 'list', ['pids' => $parentObject->id]);

if (version_compare(TYPO3_version, '9.4.0', '>=')) {
$controller = GeneralUtility::makeInstance(\TYPO3\CMS\SysNote\Controller\NoteController::class);
$content = $controller->listAction($parentObject->id, \TYPO3\CMS\SysNote\Domain\Repository\SysNoteRepository::SYS_NOTE_POSITION_TOP);
} else {
/** @var $noteBootstrap \TYPO3\CMS\SysNote\Core\Bootstrap */
$noteBootstrap = GeneralUtility::makeInstance(\TYPO3\CMS\SysNote\Core\Bootstrap::class);
$content = $noteBootstrap->run('Note', 'list', ['pids' => $parentObject->id]);
}
if ($content) {
$content = '<div class="note-container">' . $content . '</div>';


$resourcePath = ExtensionManagementUtility::extRelPath('ppi_templavoila_notes') . 'Resources/Public/';
$resourcePath = ExtensionManagementUtility::extPath('ppi_templavoila_notes') . 'Resources/Public/';
$pageRenderer = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$pageRenderer->addCssFile($resourcePath . 'Css/notes.css');
}

return $content;
}

/**
* Render inside Footer
*
* @var array $params
* @var BackendLayoutController $parentObject The TV+ BackendLayoutController
*/
public function renderFooterFunctionHook(array $params, BackendLayoutController $parentObject)
{
// Since v9LTS sys_notes we can use them on top or bottom
if (version_compare(TYPO3_version, '9.4.0', '>=')) {
$controller = GeneralUtility::makeInstance(\TYPO3\CMS\SysNote\Controller\NoteController::class);
$content = $controller->listAction($parentObject->id, \TYPO3\CMS\SysNote\Domain\Repository\SysNoteRepository::SYS_NOTE_POSITION_BOTTOM);
} else {
$content = '';
}
if ($content) {
$content = '<div class="note-container-bottom">' . $content . '</div>';


$resourcePath = ExtensionManagementUtility::extPath('ppi_templavoila_notes') . 'Resources/Public/';
$pageRenderer = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$pageRenderer->addCssFile($resourcePath . 'Css/notes.css');
}
Expand Down
3 changes: 3 additions & 0 deletions Resources/Public/Css/notes.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.note-container {
margin-bottom: 5px;
}
.note-container-bottom {
margin-top: 5px;
}

.note-container h2 {
margin-top: 0;
Expand Down
3 changes: 3 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
if (TYPO3_MODE === 'BE') {
$TYPO3_CONF_VARS['SC_OPTIONS']['templavoilaplus']['BackendLayout']['renderHeaderFunctionHook'][$_EXTKEY]
= \Ppi\PpiTemplavoilaNotes\Hooks\RenderHook::class . '->renderHeaderFunctionHook';

$TYPO3_CONF_VARS['SC_OPTIONS']['templavoilaplus']['BackendLayout']['renderFooterFunctionHook'][$_EXTKEY]
= \Ppi\PpiTemplavoilaNotes\Hooks\RenderHook::class . '->renderFooterFunctionHook';
}

0 comments on commit fe40edb

Please sign in to comment.