Galera eu uso o $this -> flash pra tudo: confirmar cadastros, negar
acesso e notificar erros.
Fiz algumas alterações no core do cake e gostaria de compartilhar com
vocês.
Primeiro vamos alterar o controlador do core: /cake/cake/libs/
controller/controller.php
A única coisa que fiz, foi adicionar a variavel $style
linha: 618
function flash($message, $url, $pause = 1, $style = null) {
$this->autoRender = false;
$this->autoLayout = false;
$this->set('url', $this->base . $url);
$this->set('message', $message);
$this->set('pause', $pause);
$this->set('page_title', $message);
$this->set('style', $style);
if (file_exists(VIEWS . 'layouts' . DS . 'flash.thtml')) {
$flash = VIEWS . 'layouts' . DS . 'flash.thtml';
} elseif ($flash = fileExistsInPath(LIBS . 'view' . DS .
'templates' . DS . "layouts" . DS . 'flash.thtml')) {
}
$this->render(null, false, $flash);
}
##########################################################################
Agora vamos mudar o layout: /cake/cake/libs/view/templates/layouts/
flash.thtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $page_title; ?></title>
<?php echo $html->charset(); ?>
<?php if (Configure::read() == 2) { ?>
<meta http-equiv="Refresh" content="<?php echo $pause; ?>;url=<?php
echo $url; ?>"/>
<?php } ?>
<style>
<!--
body { background: #fff; /* padding-top: 15%; */ }
p { text-align:center; font:bold 1.1em sans-serif }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
/* ##### Messages ##### */
.error,
.notice,
.success { padding: .8em; margin-bottom: 1em; border: 2px solid
#ddd; }
.error { background: #FBE3E4; color: #D12F19; border-color:
#FBC2C4; }
.notice { background: #FFF6BF; color: #817134; border-color:
#FFD324; }
.success { background: #E6EFC2; color: #529214; border-color:
#C6D880; }
.error a { color: #D12F19; }
.notice a { color: #817134; }
.success a { color: #529214; }
-->
</style>
</head>
<body>
<p <? if ($style) { echo 'class="'.$style.'"'; } ?> >
<a href="<?php echo $url; ?>"><?php echo $message; ?></a><br />
<a href="<?php echo $url; ?>"><span style="font-size:10px;">(clique
aqui para continuar)</span></a>
</p>
</body>
</html>
##########################################################################
Pronto, agora toda vez que você for chamar o flash dentro dos seus
controladores faça da seguinte maneira
$this -> flash('Mensagem', 'link', NULL, 'success');
$this -> flash('Mensagem', 'link', NULL, 'notice');
$this -> flash('Mensagem', 'link', NULL, error');
por favor comentem
--~--~---------~--~----~------------~-------~--~----~
Você recebeu esta mensagem porque está inscrito no Grupo "Cake PHP Português"
em Grupos do Google.
Para postar neste grupo, envie um e-mail para [email protected]
Para cancelar a sua inscrição neste grupo, envie um e-mail para [EMAIL
PROTECTED]
Para ver mais opções, visite este grupo em
http://groups.google.com/group/cake-php-pt?hl=pt-BR
-~----------~----~----~----~------~----~------~--~---