Yo lo que hago es mejor un controller plugin, que me inyecta automaticamente los mensajes en el view, y con un view helper los despliego, así me evito tener que pasarlos a la vista o comprobarlos, dejo el ejemplo:
Código PHP:
Ver original<?php
//
// +------------------------------------------------------------------------+
// | Gecko Framework |
// +------------------------------------------------------------------------+
//
require_once 'Zend/Controller/Plugin/Abstract.php';
/**
* Gecko_Controller_Plugin_FlashRenderer
*
* Zend Controller Plugin for setting the flash messages
*
* @package \Gecko\Controller\Plugin;
* @access public
**/
class Gecko_Controller_Plugin_FlashRenderer
extends Zend_Controller_Plugin_Abstract {
/**
* Check if there are Messages and assing them to the view
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function preDispatch(Zend_Controller_Request_Abstract $request) {
$FlashMessenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
$aMessages = $FlashMessenger->getMessages();
$ViewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$ViewRenderer->initView();
$ViewRenderer->view->FlashMessages = $aMessages;
}
}
Código PHP:
Ver original<?php
//
// +------------------------------------------------------------------------+
// | Gecko Framework |
// +------------------------------------------------------------------------+
//
require_once 'Zend/View/Helper/Abstract.php';
/**
* Gecko_View_Helper_DisplayFlashMessages
*
* Zend View Helper Plugin to display Session Flash Messages
*
* @package \Gecko\View\Helper;
* @access public
**/
class Gecko_View_Helper_DisplayFlashMessages extends Zend_View_Helper_Abstract
{
public function displayFlashMessages()
{
$aMessages = $this->view->FlashMessages;
if (count($aMessages) > 0) { $sMessageOutput = '<div id="flashM" title="Mensaje"><ul>';
foreach ($aMessages as $sMessage) {
$sMessageOutput .= '<li>' . $sMessage . '</li>';
}
$sMessageOutput .= '</ul></div>';
$jQuery = $this->view->jQuery();
$jQuery->enable()->uiEnable(); // enable jQuery Core Library
$jqHandler = ZendX_JQuery_View_Helper_JQuery::getJQueryHandler();
$sJqueryScript = $jqHandler.'("#flashM").dialog({
modal:true,
buttons: {
Ok: function() {
'.$jqHandler.'(this).dialog("close");
}
}
});';
$jQuery->addOnload($sJqueryScript);
return $sMessageOutput;
}
}
}
Para desplegarlos uso jQuery y creo un dialog con jQueryUI.
Saludos.