I have flashed a lot of people. Let me qualify that, I have used $this->Session->setFlash a lot of times in my time with CakePHP. In all those thousands of flashes I can break them into just 4 categories: auth, good, bad, and notices
The categories are fairly simple to understand their purposes so I am not really going to go into that but each one in my mind should have a different presentation and because of that I put a little trick into my app_controllers to allow me to simplify the process of defining the flash type. I make 3 functions in my app_controllers, infoFlash, goodFlash and badFlash which all just call the session component through it's setFlash method
Set flash is a part of the session component and is defined as
setFlash($message, $layout = 'default', $params = array(), $key = 'flash')
to call it from a controller normaly, call $this->Session->setFlash and put the other half of the session component (the session helper) in your layout.
<?php
$session->flash('flash');
$session->flash('auth');
$session->flash('good');
$session->flash('bad');
?>
However if you just add this to your app_controller, you'll be able to type $this->(info|good|bad)Flash('Your message in here'); and be able to flash a message quickly and in a very nice looking manner. This is how I definied my flash functions, you may certainly do it in any way you want but here is a sample.
function infoFlash($message, $layout = 'default', $params = array()) {
return $this->Session->setFlash($message, $layout, $params);
}
function goodFlash($message, $layout = 'default', $params = array()) {
return $this->Session->setFlash($message, $layout, $params, 'good');
}
function badFlash($message, $layout = 'default', $params = array()) {
return $this->Session->setFlash($message, $layout, $params, 'bad');
}
And now the associated css. I keep a small good/info/bad png image that is 16px by 16px in my img folder so I will use those. Change as necessary.
#goodMessage {
background:#9CED60 url('/img/good.png') no-repeat scroll 8px 11px;
border:2px solid #6CCC26;
padding:2px 0px 0px 30px;
}
#flashMessage {
background:#E6E6FF url('/img/info.png') no-repeat scroll 8px 11px;;
border: 2px solid blue;
padding: 2px 0px 0px 30px;
}
#authMessage, #badMessage {
border: 2px solid #f00;
background: #fcc url('/img/bad.png') no-repeat scroll 8px 11px;
padding: 2px 0px 0px 30px;
}
Sincerely,
~Andrew Allen