Here is how was able to get my extended controller to work

<?php
class App_Controller extends Zend_Controller_Action
{
        protected $_redirector;
        protected $_flashMessenger = null;

        public function init()
        {
                parent::init();
                $this->_flashMessenger  = 
$this->_helper->getHelper('FlashMessenger');
                $this->_redirector = $this->_helper->getHelper('Redirector');
                $this->initView();
        }

        protected function flash($message,$to)
        {
                $this->_flashMessenger->addMessage($message);
                $this->_redirector->gotoUrl($to);
        }

        protected function setMessages()
        {
                $layout = Zend_Layout::getMvcInstance();
                $layout->messages = join(" 
",$this->_flashMessenger->getMessages());
                return;
        }
        
    public function postDispatch()
        {
                parent::postDispatch();
                $this->setMessages();
        }

}

$layout = Zend_Layout::getMvcInstance();
$layout->messages = join(" ",$this->_flashMessenger->getMessages());

Then I added this to my Layout.phtml
<?php if($this->layout()->messages != ''){
                echo '<div class="flashmessages">';
                echo $this->layout()->messages;
                echo '</div>';
}?>


Ehask71 wrote:
> 
> I have a custom Controller extending Zend_Controller_Action and all my
> other controllers extend it
> 
> Here it is:
> 
> <?php
> class App_Controller extends Zend_Controller_Action
> {
>       protected $_redirector;
>       protected $_flashMessenger = null;
> 
>       public function init()
>       {
>               parent::init();
>               $this->_flashMessenger  = 
> $this->_helper->getHelper('FlashMessenger');
>               $this->_redirector = $this->_helper->getHelper('Redirector');
>               $this->initView();
>       }
> 
>       protected function flash($message,$to)
>       {
>               $this->_flashMessenger->addMessage($message);
>               $this->_redirector->gotoUrl($to);
>       }
> 
>       protected function setMessages()
>       {
>               $this->view->messages = join(" 
> ",$this->_flashMessenger->getMessages());
>       }
>     public function postDispatch()
>       {
>               parent::postDispatch();
>               $this->setMessages();
>       }
> 
> }
> 
> 
> Now I get no errors but messages not getting placed in the view i.e.
> $this->messages is always empty???   Now if I put this code in my
> controllers 
> 
> class IndexController extends App_Controller //Zend_Controller_Action
> {
> 
>     public function init()
>     {
>         /* Initialize action controller here */
>               parent::init();
>     }
> 
>     public function indexAction()
>     {
>         // action body
>         $this->view->messages =
> join("",$this->_flashMessenger->getMessages());
>     }
> 
>       public function testAction()
>     {
>         // action body
>         $this->flash('TEST FLASH','/');
>     }
> }
> 
> It works fine.  I am totally missing something I guess Matthew helped me
> get passed the errors as I was forgetting to call parent::init();    This
> one baffles me. The above base Controller works great pre 1.8.  I am still
> doing new customer sites the way I did them before 1.8 so I can keep in
> business.  Just learning on one of my personal sites to understand 1.8
> changes
> 
> Thx Again Community / Matthew for the help
> 
> Eric
> 

-- 
View this message in context: 
http://www.nabble.com/Extending-Zend_Controller_Action-tp24547887p24819663.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to