Aug 162012
Sometimes you need to disable the layout for a specific action. To do this, you simply set the view model that your action returns as “terminal”. This tells ZF2 not to wrap the returned view model with a layout.
<?php namespace Application\Controller; use Zend\Mvc\Controller\ActionController; use Zend\View\Model\ViewModel; class IndexController extends ActionController { public function nolayoutAction() { // Turn off the layout, i.e. only render the view script. $viewModel = new ViewModel(); $viewModel->setTerminal(true); return $viewModel; } }
More examples can be found in Rob Allen’s ZF2TestApp.

Noch nicht so superfein die methode, aber bei ZF2 war es eine der sachen die ich häufiger gebraucht habe.
Sorry for posting in German, comes by crossreading through different languages. Just wanted to say thanks for tutorial as this one of the things i commonly needed in ZF1
I’m wondering how to disable the layout for an entire module from the Module class. Can’t seem to find a way to do so? I should probably sign up for a mailing list or something? :-S
Lode : i’ve blogged a blog post how to disable layout in specific module. Just remove attaching event in current module if you want it effects to all modules. http://samsonasik.wordpress.com/2012/12/02/zend-framework-2-disable-layout-in-specific-module/
How do I disable the layout for error pages?
http://stackoverflow.com/questions/14727563/zf2-disable-error-page-layout/14760681#14760681