simple-flash-message Simple Flash Message is a widget for render web user flash messages with auto hide effect using JQuery.

  1. Requirements
  2. Usage

Requirements ¶

Yii 1.1 or above

Usage ¶

To set up the widget, download and extract under protected/components folder.

To render the widget for all view, you need to add the following code snippet to your main layout, place it between breadcrumbs and content:

............
        <?php if(isset($this->breadcrumbs)):?>
		<?php $this->widget('zii.widgets.CBreadcrumbs', array(
			'links'=>$this->breadcrumbs,
		)); ?><!-- breadcrumbs -->
	<?php endif?>

	// this is the widget
	<?php $this->widget('Flashes'); ?>
	
	<?php echo $content; ?>
        ............

Example usage in controller: Just like using original setFlash Yii function. Types of messages that can be used is 'success', 'error', and 'notice'.

........
        public function actionUpdate($id)
	{
	$model=$this->loadModel($id);	
		if(isset($_POST['Post']))
		{
		$model->attributes=$_POST['Post'];
		if($model->save()){
                // here is the code to set flash message
	                Yii::app()->user->setFlash('success','Save data successfully');
	                $this->redirect(array('view', 'id'=>$model->id));
			}		
		}
		$this->render('update',array(
			'model'=>$model,
		));
	}
        ...........
1 0
7 followers
977 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Developed by: wawancell wawancell
Created on: Jan 5, 2012
Last updated: 13 years ago

Downloads

show all

Related Extensions