Yii 1.1: yii-toastmessage

a smal widget to implement the jquery toast message

for a complete description of this jquery plugin please visit jquery-toastmessage

for demos Click here...


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


simply extract the download to your extensions folder

Now you can implement the toastMessage in two ways.

  1. Using the widget itself
//in your view 
//we have four types of message type : Success, Info, Warning and Error
$message = "this is yii at work";
  1. Using the view file in the views directory of the toastMessage extension. I prefer this second method when i dont want to render a view from any action.
$message = "this is a fully customized toastMessage"; 
'type'=>'warning',                                                                              'options'=>array(  'sticky'=>true,

Change Log

Official release Nov 2 2012.

#### Nov 29 2012

  • added the options property

    • inEffectDuration: 600, // in effect duration in miliseconds
    • stayTime: 3000, // time in miliseconds before the item has to disappear
    • text: '', // content of the item
    • sticky: false, // should the toast item sticky or not?
    • position: 'top-right', // top-left, top-center, top-right, middle-left, middle-center, middle-right // Position of the toast container holding different toast. // Position can be set only once at the very first call, // changing the position after the first call does nothing
    • closeText: '', // text which will be shown as close button, // set to '' when you want to introduce an image via css
    • close: null // callback function when the toastmessage is closed
  • create a new view for none rendered implement

Total 9 comments

#13286 report it
Nur Rochim at 2013/05/20 07:49pm

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\xampp\htdocs\yii\isims\protected\extensions\toastMessage\toastMessageWidget.php on line 49

#10972 report it
Sephiroth at 2012/12/07 08:55am


public function init(){
          //publish the assets folder for the toastmessage 
           $this->assets = Yii::app()->assetManager->publish(dirname(__DIR__).DIRECTORY_SEPARATOR.'toastMessage'.DIRECTORY_SEPARATOR.'assets'); 
#10970 report it
Sephiroth at 2012/12/07 07:05am

Greetings, friend I think you have a problem, check the widget file ...

#10894 report it
binkabir at 2012/11/30 04:03am

thanks for the correction. I actually had some short cut definition for some yii components, which I forgot to replace. now I have replaced it. cheers

#10883 report it
thyseus at 2012/11/29 10:19am

Please replace cs() with Yii::app()->clientScript in your code. cs() is not available everywhere.

Thanks for this extension!

#10649 report it
Daniel at 2012/11/11 07:32am

Thank you for the prompt answer, my situation is like this: Currently, I provide container to display the message (error/success/info/warning) on layouts/main.php like below:

<div style="position: fixed; top: 50px; right: 20px; z-index: 10;">
            $this->widget('bootstrap.widgets.TbAlert', array(
                'id' => 'msgBox',
                'block' => false, // display a larger alert block?
                'fade' => true, // use transitions?
                'closeText' => '&times;', // close link text - if set to false, no close link is displayed
                'alerts' => array(// configurations per alert type
                    'success' => array('block' => false, 'fade' => true, 'closeText' => '&times;'), // success, info, warning, error or danger
                    'info' => array('block' => false, 'fade' => true, 'closeText' => '&times;'),
                    'warning' => array('block' => false, 'fade' => true, 'closeText' => '&times;'),
                    'error' => array('block' => false, 'fade' => true, 'closeText' => '&times;'),
                    'danger' => array('block' => false, 'fade' => true, 'closeText' => '&times;'),
                'myHideEffect', '$("#msgBox").animate({opacity: 0.5}, 5000).fadeOut("slow");', CClientScript::POS_READY

From my TbGridView, I called

            'class' => 'bootstrap.widgets.TbButtonColumn',
            'template' => '{update} {delete}',
            'afterDelete' => "function(link,success,data){ if(success) { var obj = jQuery.parseJSON(data); $('#msgBox').html(
                                    '<div class=\"alert alert-block alert-' + obj.status + ' fade in\">' +
                                    '<a class=\"close\" data-dismiss=\"alert\">×</a>' +
                                    obj.msg + '</div>'); $('#msgBox').animate({opacity: 0.5}, 5000).fadeOut('slow');} }",

I have no idea to replace this with the toast message. Any help?



#10631 report it
binkabir at 2012/11/09 05:47am
@ Daniel

yes you can use it for dynamical ajax call but the condition is that because the js script for the extensions are only loaded on request you have to set the param ($processOutput=true) in your renderPartial method. (the default is false)

eg. $this->renderPartial('myView',array('model'=>$model),false,TRUE);

#10629 report it
Daniel at 2012/11/09 03:49am
Use as flash message


How to use it to show flash message? Also, display it dynamically after ajax call?



#10553 report it
Peter JK at 2012/11/04 10:01am
nice extension


nice extension. just about to remind me Foxpro and foxpro for windows..

Leave a comment

Please to leave your comment.

Create extension