.. include:: /Includes.rst.txt .. index:: Events; AfterLinkIsGeneratedEvent .. _AfterLinkIsGeneratedEvent: ========================= AfterLinkIsGeneratedEvent ========================= .. versionadded:: 12.0 This PSR-14 event supersedes the :php:`UrlProcessorInterface` logic which allowed to modify mail URNs or external URLs, but not the full anchor tag. In addition, this PSR-14 event also replaces the :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['typoLink_PostProc']` hook which was not executed at all times, and had a cumbersome API to modify values. It is also recommended to use the PSR-14 event instead of the global getATagParams hook (:php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getATagParamsPostProc']`) to add additional attributes (see example below) to links. The PSR-14 event :php:`\TYPO3\CMS\Frontend\Event\AfterLinkIsGeneratedEvent` allows PHP developers to modify any kind of link generated by TYPO3's mighty :php:`typolink()` functionality. By using this event, it is possible to add attributes to links to internal pages, or links to files, as the event contains the actual information of the link type with it. As this event works with the :php:`\TYPO3\CMS\Frontend\Typolink\LinkResultInterface` object it is possible to modify or replace the LinkResult information instead of working with string replacement functionality for adding, changing or removing attributes. If a link could not be generated, a :php:`\TYPO3\CMS\Frontend\Typolink\UnableToLinkException` might be thrown. Example ======= .. literalinclude:: _AfterLinkIsGeneratedEvent/_MyEventListener.php :language: php :caption: EXT:my_extension/Classes/Frontend/EventListener/MyEventListener.php .. include:: /_includes/EventsAttributeAdded.rst.txt API === .. include:: /CodeSnippets/Events/Frontend/AfterLinkIsGeneratedEvent.rst.txt