markshust/magento2-module-messages 1.0.0

The Messages module allows you to send success, notice, warning and error messages with HTML.

Type

magento2-module

License

MIT

Requires
Requires (dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

Devtomic_Messages

Magento 2.2 | 2.3 Latest Stable Version MIT License

Devtomic

The Messages module allows you to send success, notice, warning and error messages with HTML.

Installation

composer require devtomic/magento2-module-messages
bin/magento module:enable Devtomic_Messages
bin/magento setup:upgrade

Usage

Call the addComplexSuccessMessage function with the withHtml identifier. This identifer expects two arguments:

  • html: A string containing the desired HTML
  • allowed_tags: An array containing a list of strings of HTML tags to allow

Demo

This code:

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

Results in the following output:

Screenshot