Yii 1.1: hzl-toastr

Toastr, can use both in view and control, can fetch flashes set by you before, msg can show with user defined html format.
10 followers

Toastr, can use in view and control, can fetch flashes message from controller, can show link in msg info, can show several same msgs type in single file:)

This is Scott Huang(zhiliang)'s 2nd widget extention:) First is hzl-googlechart. I also include into the zip to save your time.

Leverage Toastr 2.0.1 which published at Nov 1,2013

Requirements

requirements of using this extension (e.g. Yii 1.1 or above)

Usage

1. Simple, will use type info and warning, normally write in view file, actually also can write in controller:)

$this->widget('ext.Hzl.toastr.HzlToastr', array(
            'message' => 'Please enter at least one condition to avoid huge output, thanks.',
        ));
 
        $this->widget('ext.Hzl.toastr.HzlToastr', array(
            'message' => 'A warning msg test :)',
            'title'=> 'test title',
           'type'=>'warning',  //info,success,warning,error
        ));

2. More option usage, write in view file

$this->widget('ext.Hzl.toastr.HzlToastr', array(
            'flashMessagesOnly'=> false, //default to false
            // msg will be ignore if flashMessagesOnly set to false
            'title' =>'Enhanced Usage Title',
            'message' => '<div><input class="input-small" value="textbox"/>&nbsp;<a href="http://johnpapa.net" target="_blank">This is a hyperlink</a></div><div><button type="button" id="okBtn" class="btn btn-primary">Close me</button><button type="button" id="surpriseBtn" class="btn" style="margin: 0 8px 0 8px">Surprise me</button></div>',
            //'message' => time().'temp adskfasdf',
            'type' => 'info',
            //the options passed to the plugin
            'options' => array(
                "closeButton" => true,
                "debug" => true,
                "positionClass" => "toast-top-right",
                "showDuration" => "300",
                "hideDuration" => "1000",
                "timeOut" => "15000",
                "extendedTimeOut" => "1000",
                "showEasing" => "swing",
                "hideEasing" => "linear",
                "showMethod" => "fadeIn",
                "hideMethod" => "fadeOut"
            )
        ));

3. Enhanced usage with flash, normally set flash in controller, and get flash from view

a. In controller
//set some msg
            //Type will identify by title words, such as type will set by Success if title include success/Success word
                    Yii::app()->user->setFlash('No this Type', 'my test2: The model was saved with success');
                    Yii::app()->user->setFlash('Success:  Contact: ', 'Thank you for contacting us. We will respond to you as soon as possible.');
                    Yii::app()->user->setFlash('error', 'my test: The model was saved with success');
b. call message in view
http://codeseven.github.io/toastr/demo.html
            $this->widget('ext.Hzl.toastr.HzlToastr', array(
                'flashMessagesOnly' => true, //default to false.  True will fetch setFlashes data
                'options' => array(
                    'timeOut' => 8000,
                )
            ));

Add: I usually define one common func in component folder and call it easily.

public static function setMsg($title = '', $msg = '') {
        //yii::app()->user->setFlash(str_replace(array("'", '"'), array('`', '\"'), $title), str_replace(array("'", '"'), array('`', '\"'), $msg));
        yii::app()->user->setFlash(str_replace(array("'"), array('`'), $title), str_replace(array("'"), array('`'), $msg));
    }

Result

HzlToastr Result

Resource

Toastr Live Demo

Total 3 comments

#15968 report it
Scott_Huang at 2014/01/05 06:29am
:) It have improvements if compare to @Cherif's Etoastr

Thanks @Cherif for your comments.

My widget have several improvements:
1. Can show several msgs even same time in same page.
2. Flashes title can also serve both for type and title.
3. More robust.

#15966 report it
Cherif at 2014/01/05 02:54am
Thanks, ducplicated ext

Hi, Thank you for the extension but I just want to mention that I have already developed an extensions for this Etoastr.

#15946 report it
Scott_Huang at 2014/01/02 05:47am
Default HzlToastr Options FYI:
public $options = array();
public $responsive = false;
public $message = '';
public $title = '';
public $type = 'info'; 
public $positionClass;
public $flashMessagesOnly = false;
public $flashDeleteAfterRead = True;

Leave a comment

Please to leave your comment.

Create extension