Zend Framework Source Code Snippets

Disable view renderer and layout within controllers

Bookmark and Share
1
2
3
4
56
7
8
9
1011
<?php
 
class MyController extends Zend_Controller_Action
{
     public function indexAction() {
        $this->getHelper('layout')->disableLayout();
        $this->getHelper('viewRenderer')->setNoRender();
    }
 }

Comments

fedecarg fedecarg
1 year ago

I'd recommend checking if the Layout helper is defined before disabling the layout:

<pre>
if ($this->_helper->hasHelper('Layout')) {
$this->_helper->layout->disableLayout();
}
</pre>

That way you avoid producing errors when using PHPUnit.

You must login before commenting on a snippet. If you do not have an account, please register.

Snippet description

How to stop the automatic view and layout rendering within your controller actions.

Snippet details

Created:
davedevelopment davedevelopment
1 year ago
Edited:
davedevelopment davedevelopment
1 year ago
Revision Id:
2
Edit Message:
Initial Release
Tags:
action helper view renderer controller
Comments:
1
Views:
383
Points:
0 (0 votes)

History

r2

Initial Release

davedevelopment davedevelopment
1 year ago