AfterRawPageRowPreparedEvent¶
New in version 13.3
This event was introduced to replace the hook
$GLOBALS
which has already been removed with TYPO3 v9.
The PSR-14 event
\TYPO3\
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¶
<?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);
}
}
}
API of AfterRawPageRowPreparedEvent¶
- class AfterRawPageRowPreparedEvent ¶
-
- Fully qualified name
-
\TYPO3\
CMS\ Backend\ Tree\ Repository\ After Raw Page Row Prepared Event
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