ModifyPageLayoutContentEvent¶
New in version 12.0
This event serves as a replacement for the removed hooks:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook']
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawFooterHook']
The PSR-14 event \TYPO3\CMS\Backend\Controller\Event\ModifyPageLayoutContentEvent
allows to modify page module content.
It is possible to add additional content, overwrite existing content or reorder the content.
Example¶
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Backend\EventListener;
use TYPO3\CMS\Backend\Controller\Event\ModifyPageLayoutContentEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
#[AsEventListener(
identifier: 'my-extension/backend/modify-page-module-content',
)]
final readonly class MyEventListener
{
public function __invoke(ModifyPageLayoutContentEvent $event): void
{
// Get the current page ID
$id = (int)($event->getRequest()->getQueryParams()['id'] ?? 0);
$event->addHeaderContent('Additional header content');
$event->setFooterContent('Overwrite footer content');
}
}
New in version 13.0
The PHP attribute \TYPO3\CMS\Core\Attribute\AsEventListener
has been
introduced to tag a PHP class as an event listener. Alternatively, or if you
need to be compatible with older TYPO3 versions, you can also register an
event listener via the Configuration/Services.yaml
file. Switch to
an older version of this page for an example or have a look at the section
Implementing an event listener in your extension.
API¶
- class \TYPO3\CMS\Backend\Controller\Event\ ModifyPageLayoutContentEvent¶
-
Listeners to this Event will be able to modify the header and footer content of the page module
- getRequest ( ) ¶
-
- returntype
-
Psr\Http\Message\ServerRequestInterface
- getModuleTemplate ( ) ¶
-
- returntype
-
TYPO3\CMS\Backend\Template\ModuleTemplate
- setHeaderContent ( string $content) ¶
-
Set content for the header. Can also be used to e.g. reorder existing content.
IMPORTANT: This overwrites existing content from previous listeners!
- param string $content
-
the content
- addHeaderContent ( string $content) ¶
-
Add additional content to the header
- param string $content
-
the content
- getHeaderContent ( ) ¶
-
- returntype
-
string
-
Set content for the footer. Can also be used to e.g. reorder existing content.
IMPORTANT: This overwrites existing content from previous listeners!
- param string $content
-
the content
-
Add additional content to the footer
- param string $content
-
the content
-
- returntype
-
string