If you want to use a different layout in the same module using Zend Framework 2, just use the example bellow inside your action:

1
2
3
$layout = $this->layout();
$layout->setTemplate('layout/new_layout');
return new ViewModel();

This is going to use “new_layout.phtml” file as the layout file, ignoring the default layout of the module.

Comments