Type of Flash Messenger in Zend

后端 未结 4 555
遥遥无期
遥遥无期 2021-02-02 15:25

Is it possible or How can i give a type to a FlashMessage in Zend?

For example

/* This is a \"Success\" message */
$this -> _helper -> FlashMesseng         


        
4条回答
  •  误落风尘
    2021-02-02 15:50

    I think the best way to do this is by using the flashmessenger namespaces:

    /* success message */
    $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Post created!');
    
    /* error message */
    $this->_helper->FlashMessenger()->setNamespace('error')->addMessage('You have no permissions');
    

    And then in your layout you can get the messages added to each namespace:

    setNamespace('success')->hasMessages()): ?>
        
    getMessages() as $msg): ?>
    setNamespace('error')->hasMessages()): ?>
    getMessages() as $msg): ?>

提交回复
热议问题