typo3backendtypo3-12.x

TYPO3 backend event listener: Find out if Web > Page module is active


I want to add a "edit custom record" button to the doc header of the typo3 backend when the "Web > Page" module is active.

This is possible by registering a listener to the modify-button-bar event and works fine.

In my event listener class, I obtain the ID of the currently selected page with

$pageUid = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');

The problem now is that the button is also shown when the Web > View, Web > List, Web > Info modules are active.

Unfortunately, there are no other GET parameters than id and token.

How can I find out if the "Web > Page" module is active?


Solution

  • There is no official way to obtain the request object in event listeners in v12, so I have to resort to the global object:

    $GLOBALS['TYPO3_REQUEST']->getAttribute('route')->getOption('_identifier');
    

    It will return web_layout.