Mecha CMS

Mecha CMS blog and documentation.

Class Notify

Updated: Sunday, 07 August 2016

Notification messages.

This class is used to display notification messages which will appear once per page visit, usually just after something has been submitted.


Notify::info('This is an info message.');


echo Notify::read();


Notify::success('This is a success message.');
Notify::info('This is an info message.');
Notify::warning('This is a warning message.');
Notify::error('This is an error message.');

echo Notify::read();



Counting Errors

When error and warning messages displayed, it will also increase the internal value of $errors variable inside the Notify class in the background. This is useful for limiting actions only if no errors occurred:

if( ! Notify::errors()) {
    echo 'It is OK.';

Custom Notification Message

// create
Notify::plug('my_custom_message', function($text, $icon = 'bell-o') {
    Notify::bare($text, $icon, 'custom-class');

// usage
Notify::my_custom_message('Hello there!');

// print
echo Notify::read();


<div class="messages cl cf">
  <p class="message cl cf">
    <i class="fa fa-fw fa-bell-o"></i> Hello there!

Email Notification

Added since version 1.1.0.

$from = '';
$to = '';
$subject = 'New message!';
$message = 'Test message.';

if(Notify::send($from, $to, $subject, $message)) {
    echo 'Sent!';
Donation and Email Subscription