📊 State of Magento 2025

The Home for Magento 2 Excellence

Quality-tested Magento 2 modules. Explore. Evaluate. Elevate. #magento2

606 Modules
385 Ready
218 Need Help
🏆 Leaderboard
Potentially Abandoned v1.0.0

MarkShust_Messages

markshust/magento2-module-messages

This extensions allows us to send success, notice, warning, and error messages with embedded HTML.

34
Downloads
Below average
56
GitHub Stars
Above average
7y ago
Last Release
1
Open Issues
Build Issues
0/3 checks passed

Build Tests

Composer Install
DI Compile
Templates

Code Quality

CS Coding Standard
PHPStan

Tested on Magento 2.4.8-p3

Recent Test History

Each release is tested against the latest Magento version at that time.

v1.0.0 on Magento 2.4.8-p3
Dec 16, 2025
v1.0.0 on Magento 2.4.8-p2
Aug 14, 2025
v1.0.0 on Magento 2.4.8
May 21, 2025
v1.0.0 on Magento 2.4.7-p4
Feb 15, 2025
v1.0.0 on Magento 2.4.7-p3
Oct 20, 2024
v1.0.0 on Magento 2.4.7-p2
Sep 8, 2024

+4 older tests

Looking for Contributors

Composer installation fails. Your contribution could help the entire Magento community!

Contribute

Share This Module's Status

MarkShust_Messages Magento compatibility status badge

README

Loaded from GitHub

Table of contents

Summary

By default, when you call $this->messageManager->addSuccessMessage within Magento, you cannot pass custom HTML into your message. This doesn't provide you with the flexibility to provide customized messages to your visitors.

This module provides the ability to display custom messages including HTML, and still escapes the HTML to prevent cross-site scripting (XSS) attacks.

Installation

composer require markshust/magento2-module-messages
bin/magento module:enable MarkShust_Messages
bin/magento setup:upgrade

API

/**
 * Any of the built-in complex message functions can be called with this identifer:
 *     addComplexSuccessMessage
 *     addComplexNoticeMessage
 *     addComplexWarningMessage
 *     addComplexErrorMessage
 * 
 * @param string $identifer Set to 'withHtml' to use this module.
 * @param mixed[] $data Data containing elements.
 *     @type string 'html' Desired output including HTML.
 *     @type string[] 'allowed_tags' (optional) List of allowed tags to render as HTML.
 */
$this->messageManager->addComplexSuccessMessage($identifer, $data);

Usage

protected messageManager;
 
public function __construct(
    ... 
    \Magento\Framework\Message\ManagerInterface $messageManager,
    ...
) {
    $this->messageManager = $messageManager;
    ...
}

$this->messageManager->addComplexSuccessMessage('withHtml', [
    'html' => '<b>This is bold text!</b> And this is not.',
    'allowed_tags' => ['b'],
]);

Screenshot

License

MIT

This content is fetched directly from the module's GitHub repository. We are not the authors of this content and take no responsibility for its accuracy, completeness, or any consequences arising from its use.