问题
I want to display my flash messages in my application's layout file - not sure how to access it though. I set the value in my action.
回答1:
Try my view helper - https://github.com/philBrown/Tolerable/blob/master/library/Tolerable/View/Helper/FlashMessenger.php
This even includes translations if you have them configured.
To display messages from the default namespace, simply use
<?php echo $this->flashMessenger() ?>
To set a namespace, provide it as the first argument
<?php echo $this->flashMessenger('errors') ?>
The default is to render each message in an unordered list however you can change that by providing a view partial
<?php echo $this->flashMessenger(null, 'flash-messages-partial.phtml') ?>
来源:https://stackoverflow.com/questions/7285131/how-do-i-access-flashmessenger-in-my-layout-file-in-zend-framework