ModifyInfoModuleContentEvent

New in version 12.0

This event has been introduced as a more powerful and flexible alternative to $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/web_info/class.tx_cms_webinfo.php']['drawFooterHook'] which has now been removed.

The PSR-14 event \TYPO3\CMS\Info\Controller\Event\ModifyInfoModuleContentEvent allows the content above and below the info module to be modified. The content added in the event is displayed in each submodule of Web > Info.

The event also provides the getCurrentModule() method, which returns the current requested submodule. It is therefore possible to limit the added content to a subset of the available submodules.

Next to getRequest() and the getModuleTemplate() methods this event also features getters and setters for the header and footer content.

Access control

The added content is by default always displayed. This event provides the hasAccess() method, returning whether the access checks in the module were passed by the user.

This way, event listeners can decide on their own, whether their content should always be shown, or only if a user also has access to the main module content.

Example

EXT:my_extension/Classes/Info/EventListener/MyEventListener.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Info\EventListener;

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Info\Controller\Event\ModifyInfoModuleContentEvent;

#[AsEventListener(
    identifier: 'my-extension/content-to-info-module',
)]
final readonly class MyEventListener
{
    public function __invoke(ModifyInfoModuleContentEvent $event): void
    {
        // Add header content for the "Localization overview" submodule,
        // if user has access to module content
        if (
            $event->hasAccess() &&
            $event->getCurrentModule()->getIdentifier() === 'web_info_translations'
        ) {
            $event->addHeaderContent('<h3>Additional header content</h3>');
        }
    }
}
Copied!

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 ModifyInfoModuleContentEvent
Fully qualified name
\TYPO3\CMS\Info\Controller\Event\ModifyInfoModuleContentEvent

Listeners to this Event will be able to modify the header and footer content of the info module

hasAccess ( )

Whether the current user has access to the main content of the info module.

IMPORTANT: This is only for informational purposes. Listeners can therefore decide on their own if their content should be added to the module even if the user does not have access to the main module content.

Returns
bool
getRequest ( )
Returns
\Psr\Http\Message\ServerRequestInterface
getCurrentModule ( )
Returns
\TYPO3\CMS\Backend\Module\ModuleInterface
getModuleTemplate ( )
Returns
\TYPO3\CMS\Backend\Template\ModuleTemplate
setHeaderContent ( string $content)

Set content for the header. Can also be used to e.g. reorder existing content.

IMPORTANT: This overwrites existing content from previous listeners!

param $content

the content

addHeaderContent ( string $content)

Add additional content to the header

param $content

the content

getHeaderContent ( )
Returns
string
setFooterContent ( string $content)

Set content for the footer. Can also be used to e.g. reorder existing content.

IMPORTANT: This overwrites existing content from previous listeners!

param $content

the content

addFooterContent ( string $content)

Add additional content to the footer

param $content

the content

getFooterContent ( )
Returns
string