Setting up Zend Layout from Bootstrap

て烟熏妆下的殇ゞ 提交于 2019-12-24 07:15:55

问题


I want to define the which Layout the Zend_Layout should use from Bootstrap class. How to do this?

Like from the controller you can do something like

$this->_helper->_layout = "somelayout";

I want to change the layout from the bootstrap class.


回答1:


You could do it as follows:

public function _initLayout() {
    $layout = $this->bootstrap('layout')->getResource('layout');
    $layout->setLayout('somelayout');
}



回答2:


You can look further into it on these pages :

http://framework.zend.com/manual/en/zend.layout.quickstart.html

http://framework.zend.com/manual/en/zend.layout.options.html

The second one is more helpful, but make sure that you read "Using Zend_Layout with the Zend Framework MVC" in the first page.

If you want to start the layout strictly from the bootstrap you can do the following.


public function _initMyLayout()
{
     $options = array(
    'layout'     => 'somelayout',
    'layoutPath' => '/path/to/layouts',
    'contentKey' => 'CONTENT'
     };


     $layout = Zend_Layout::startMvc($options);

     return $layout;

}

The above would be equivalent to you specifying a default script and path in your .ini file.



来源:https://stackoverflow.com/questions/5977226/setting-up-zend-layout-from-bootstrap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!