Sending variables to the layout in Zend Framework

后端 未结 8 1638
[愿得一人]
[愿得一人] 2020-11-28 06:45

In my project I have a number of dynamic elements that are consistently on every page. I have put these in my layout.phtml

My question is: How can I send variables i

8条回答
  •  感动是毒
    2020-11-28 07:30

    class IndexController extends Zend_Controller_Action
    {
    
       public function init()
       {
          $this->_layout = $this->_helper->layout->getLayoutInstance();
          $this->_layout->whatever = $this->view->render('test.phtml);
       }
    }
    

    In the layout file you can call

    layout()->whatever ?>

    If in some actions if you don't want that section then:

    public function viewAction()
    {
       $this->_layout->whatever = null;
    }
    

提交回复
热议问题