I am learning ZF2.0 beta. In ZF1 we can change layout on the fly in controller:
Zend_Layout::getMvcInstance()->setLayout(\'layoutname\');
The best way I've found to set templates in actions is like this
public function someAction() {
$viewModel = new ViewModel();
$viewModel->setTemplate('layout/custom');
return $viewModel;
}
In your module.config.php
make sure you've set your appropriate template_map
path.
'view_manager' => array(
'template_map' => array(
'layout/custom' => __DIR__ . '/../view/layout/custom.phtml'
),
),