getSystemMessages

The getSystemMessages hook allows to add additional messages to the back end home screen. It does not pass any parameters and expects a string as return value.

Return Values

Return a string with the message(s) you want to add to the home screen (including HTML markup) or an empty string.

Example

// src/EventListener/GetSystemMessagesListener.php
namespace App\EventListener;

use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;

#[AsHook('getSystemMessages')]
class GetSystemMessagesListener
{
    public function __invoke(): string
    {
        // Display a warning if the system admin's email is not set
        if (empty($GLOBALS['TL_ADMIN_EMAIL'])) {
            return '<p class="tl_error">Please add your email address to system settings.</p>';
        }

        return '';
    }
}

References