AfterRawPageRowPreparedEvent

New in version 13.3

The PSR-14 event \TYPO3\CMS\Backend\Tree\Repository\AfterRawPageRowPreparedEvent allows to modify the populated properties of a page and children records before the page is displayed in a page tree.

This can be used, for example, to change the title of a page or apply a different sorting to its children.

Example: Sort pages by title in the page tree

EXT:my_extension/Classes/Backend/EventListener/MyEventListener.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Backend\EventListener;

use TYPO3\CMS\Backend\Tree\Repository\AfterRawPageRowPreparedEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;

final class MyEventListener
{
    #[AsEventListener]
    public function __invoke(AfterRawPageRowPreparedEvent $event): void
    {
        $rawPage = $event->getRawPage();
        if ((int)$rawPage['uid'] === 123) {
            // Sort pages alphabetically in the page tree
            $rawPage['_children'] = usort(
                $rawPage['_children'],
                static fn(array $a, array $b) => strcmp($a['title'], $b['title']),
            );
            $rawPage['title'] = 'Some special title';
            $event->setRawPage($rawPage);
        }
    }
}
Copied!

API of AfterRawPageRowPreparedEvent

class AfterRawPageRowPreparedEvent
Fully qualified name
\TYPO3\CMS\Backend\Tree\Repository\AfterRawPageRowPreparedEvent

Listeners to this event will be able to modify a page with the special _children key, or completely change e.g. a title.

getRawPage ( )
Returns
array
setRawPage ( array $rawPage)
param $rawPage

the rawPage

getWorkspaceId ( )
Returns
int