Change layout in the controller of Zend Framework 2.0

前端 未结 5 1105
旧巷少年郎
旧巷少年郎 2020-12-10 00:57

I am learning ZF2.0 beta. In ZF1 we can change layout on the fly in controller:

Zend_Layout::getMvcInstance()->setLayout(\'layoutname\');         


        
5条回答
  •  不思量自难忘°
    2020-12-10 01:45

    You will also have to set the layout either in the bootstrap or when using di. Di example:

        'Zend\View\Resolver\TemplateMapResolver' => array(
            'parameters' => array(
                'map'  => array(
                'layout/different' => __DIR__ . '/../view/layout/different.phtml',
                ),
            ),
        ),
    

提交回复
热议问题