AfterPageTreeItemsPreparedEvent
New in version 12.0
This PSR-14 event replaces the following hooks:
The PSR-14 event
\TYPO3\
allows prepared page tree items to be modified.
It is dispatched in the \TYPO3\
class after the page tree items have been resolved and prepared. The event
provides the current PSR-7 request object as well as the page tree items. All
items contain the corresponding page record in the special _page
key.
Example
Registration of the event listener in the extension's Services.
:
services:
# Place here the default dependency injection configuration
MyVendor\MyExtension\Backend\EventListener\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/backend/modify-page-tree-items'
Read how to configure dependency injection in extensions.
The corresponding event listener class:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Backend\EventListener;
use TYPO3\CMS\Backend\Controller\Event\AfterPageTreeItemsPreparedEvent;
final class MyEventListener
{
public function __invoke(AfterPageTreeItemsPreparedEvent $event): void
{
$items = $event->getItems();
foreach ($items as $item) {
// Set special icon for page with ID 123
if ($item['_page']['uid'] === 123) {
$item['icon'] = 'my-special-icon';
}
}
$event->setItems($items);
}
}