Sometimes you want to disable default layout & view rendering in Zend Framework, for example to output a JSON response. The following bolded two lines do the job:
public function vouchersForNumberAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); ... $data = new Zend_Dojo_Data('code', $vouchers, 'title'); header('Content-Type: application/json'); echo $data->toJson(); }
No comments:
Post a Comment