ModifyPageLinkConfigurationEvent¶
New in version 12.0
This event has been introduced to serve as a more powerful and flexible
alternative for the removed hook
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typolinkProcessing']['typolinkModifyParameterForPageLinks']
.
The PSR-14 event \TYPO3\CMS\Frontend\Event\ModifyPageLinkConfigurationEvent
is called after a page has been resolved, and includes arguments such as the
generated fragment and the to-be-used query parameters.
The page to be linked to can also be modified to link to a different page.
Example¶
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Frontend\EventListener;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Frontend\Event\ModifyPageLinkConfigurationEvent;
#[AsEventListener(
identifier: 'my-extension/modify-page-link-configuration',
)]
final readonly class MyEventListener
{
public function __invoke(ModifyPageLinkConfigurationEvent $event): void
{
// Do your magic here
}
}
New in version 13.0
The PHP attribute \TYPO3\CMS\Core\Attribute\AsEventListener
has been
introduced to tag a PHP class as an event listener. Alternatively, or if you
need to be compatible with older TYPO3 versions, you can also register an
event listener via the Configuration/Services.yaml
file. Switch to
an older version of this page for an example or have a look at the section
Implementing an event listener in your extension.
API¶
- class \TYPO3\CMS\Frontend\Event\ ModifyPageLinkConfigurationEvent¶
-
A generic PSR 14 Event to allow modifying the incoming (and resolved) page when building a "page link".
This event allows Event Listener to change the page to be linked to, or add/remove possible query parameters / fragments to be generated.
- getConfiguration ( ) ¶
-
- returntype
-
array
- setConfiguration ( array $configuration) ¶
-
- param array $configuration
-
the configuration
- getLinkDetails ( ) ¶
-
- returntype
-
array
- getPage ( ) ¶
-
- returntype
-
array
- setPage ( array $page) ¶
-
- param array $page
-
the page
- getQueryParameters ( ) ¶
-
- returntype
-
array
- setQueryParameters ( array $queryParameters) ¶
-
- param array $queryParameters
-
the queryParameters
- getFragment ( ) ¶
-
- returntype
-
string
- setFragment ( string $fragment) ¶
-
- param string $fragment
-
the fragment
- pageWasModified ( ) ¶
-
- returntype
-
bool