if someone wants to disable both the layout and viewing using the controller plugin, here is the preDispatch hook that I worked with through various articles and answers, including this one. Hope this helps someone and saves time.
// in Controller Plugin public function preDispatch(){ //if its an AJAX request then disable layout and view. if ($this->_request->isXmlHttpRequest() || isset($_GET['ajax'])){ // disable layout $layout = Zend_Controller_Action_HelperBroker::getExistingHelper('Layout'); $layout->disableLayout(); // disable view $viewRenderer = Zend_Controller_Action_HelperBroker::getExistingHelper('viewRenderer'); $viewRenderer->setNeverRender(true); } }
Tahir source share