AfterPageTreeItemsPreparedEvent

New in version 12.0: This PSR-14 event replaces the following hooks:

  • $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Workspaces\Service\WorkspaceService']['hasPageRecordVersions']

  • $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Workspaces\Service\WorkspaceService']['fetchPagesWithVersionsInTable']

This event allows prepared page tree items to be modified.

It is dispatched in the TYPO3\CMS\Backend\Controller\Page\TreeController class after the page tree items have been resolved and prepared. The event provides the current PSR-7 request as well as the page tree items. All items contain the corresponding page record in the special _page key.

Example

Registration of the event in your extensions' Services.yaml:

EXT:my_extension/Configuration/Services.yaml
MyVendor\MyExtension\Workspaces\MyEventListener:
  tags:
    - name: event.listener
      identifier: 'my-extension/workspaces/modify-page-tree-items'

The corresponding event listener class:

EXT:my_extension/Classes/Workspaces/MyEventListener.php
use TYPO3\CMS\Backend\Controller\Event\AfterPageTreeItemsPreparedEvent;

final class MyEventListener
{
    public function __invoke(AfterPageTreeItemsPreparedEvent $event): void
    {
        $items = $event->getItems();
        foreach ($items as $item) {
            // Setting special item for page with id 123
            if ($item['_page']['uid'] === 123) {
                $item['icon'] = 'my-special-icon';
            }
        }
        $event->setItems($items);
    }
}

API

class TYPO3\CMS\Backend\Controller\Event\AfterPageTreeItemsPreparedEvent

Listeners to this event will be able to modify the prepared page tree items for the page tree

getRequest()
Return type

Psr\Http\Message\ServerRequestInterface

getItems()
Return type

array

setItems(array items)
Parameters
  • $items (array) -- the items