---
title: "Feature: #97945 - PSR-14 AfterPageTreeItemsPreparedEvent"
manual: "TYPO3 Core Changelog"
version: "main"
permalink: "https://docs.typo3.org/permalink/changelog:feature-97945"
source: "Changelog/12.0/Feature-97945-PSR14AfterPageTreeItemsPreparedEvent.rst"
typo3-version: "12.0"
typo3-major: 12
type: "feature"
issue: 97945
forge: "https://forge.typo3.org/issues/97945"
tags: ["Backend", "PHP-API", "ext:backend"]
rendered: "2026-09-17T21:17:42+00:00"
---

# Feature: #97945 - PSR-14 AfterPageTreeItemsPreparedEvent {#feature-97945-psr-14-afterpagetreeitemspreparedevent}

See [forge#97945](https://forge.typo3.org/issues/97945)

## Description {#description}

A new PSR-14 event `\TYPO3\CMS\Backend\Controller\Event\AfterPageTreeItemsPreparedEvent`
has been introduced which allows to modify prepared page tree items. It can also
be used as a replacement for the now removed
`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Workspaces\Service\WorkspaceService']['hasPageRecordVersions']`
and `$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Workspaces\Service\WorkspaceService']['fetchPagesWithVersionsInTable']`
[hooks](https://docs.typo3.org/permalink/changelog:breaking-97945).

The event is dispatched in the `TreeController` 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 {#example}

Registration of the event in your extension's `Services.yaml` file:

```yaml
MyVendor\MyPackage\Workspaces\MyEventListener:
  tags:
    - name: event.listener
      identifier: 'my-package/workspaces/modify-page-tree-items'
```

The corresponding event listener class:

```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);
    }
}
```

## Impact {#impact}

It is now possible to modify the prepared page tree items before they are
returned by the `TreeController`, using the new PSR-14 event
`AfterPageTreeItemsPreparedEvent`.
