BeforePagePreviewUriGeneratedEvent
New in version 12.0
This PSR-14 event replaces the
$GLOBALS
preProcess hook.
The \TYPO3\
is executed in \TYPO3\
, before the preview
URI is actually built. It allows to either adjust the parameters, such as the
page id or the language id, or to set a custom preview URI, which will then stop
the event propagation and also prevents
\TYPO3\
from building the URI based
on the parameters.
Note
The overwritten parameters are used for building the URI and are also passed
to the AfterPagePreviewUriGeneratedEvent. They however do not
overwrite the related class properties in Preview
.
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-parameters'
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\Routing\Event\BeforePagePreviewUriGeneratedEvent;
final class MyEventListener
{
public function __invoke(BeforePagePreviewUriGeneratedEvent $event): void
{
// Add custom query parameter before URI generation
$event->setAdditionalQueryParameters(
array_replace_recursive(
$event->getAdditionalQueryParameters(),
['myParam' => 'paramValue'],
),
);
}
}
API
- class BeforePagePreviewUriGeneratedEvent
-
- Fully qualified name
-
\TYPO3\
CMS\ Backend\ Routing\ Event\ Before Page Preview Uri Generated Event
Listeners to this event will be able to modify the corresponding parameters, before the page preview URI is being generated, when linking to a page in the frontend.