mrN
mrN

Reputation: 3770

Setting up Zend Layout from Bootstrap

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.

Upvotes: 1

Views: 3006

Answers (2)

Jerry Saravia
Jerry Saravia

Reputation: 3837

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.

Upvotes: 0

Marcin
Marcin

Reputation: 238259

You could do it as follows:

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

Upvotes: 2

Related Questions