Well, I wasn't expecting that code response Kizano. It's almost verbatim to what I did as a quick work around. How dare you peek at my code :-P
Thanks for both yours and Hector's responses. They were both helpful and provided enough info that I can work the rest of it out. Thanks! -Tim On Mon, Mar 7, 2011 at 12:25 AM, Markizano Draconus <asthral...@gmail.com> wrote: > Hey Tim, > > You could add something to disable the layout and set the proper headers: > In the controller, under init() or the action you want to execute: > > > $this->_helper->layout->disableLayout(); > $this->_response->setHeader('Content-Type', 'application/json'); > $this->view->json = array( > 'status' => 'ok', > 'message' => 'This is a status message.', > ); > > > In application/scripts/view/index/index.phtml (or wherever your view scripts > are): > > <?php print $this->json; ?> > > It's probably looking for error.phtml because it's missing the view scripts > for the error controller to render the HTML for the error and exceptions. > Try adding that and your debugging might be made a bit easier ;) > > > Hope this helps, > -Kizano > //----- > Information Security > eMail: asthral...@gmail.com > http://www.markizano.net/ > > On 03/06/2011 10:49 PM, Tim wrote: >> >> I can't seem to get my controllers to recognize that I only want them >> to display json. Here's my controller >> >> <?php >> >> class IndexController extends Zend_Controller_Action { >> public function init() { >> $this->_helper->contextSwitch() >> ->clearContexts() >> ->clearActionContexts() >> ->setDefaultContext('json') >> ->initContext('json'); >> } >> >> public function indexAction() { >> $this->view->assign(array( >> 'status' => 'ok', >> 'message' => 'This is the index action' >> )); >> } >> } >> >> ?> >> >> >> All I want to do is, by default, output everything as json. I don't >> want to have to send a "format=json" parameter in the URL. >> >> According to >> http://framework.zend.com/manual/en/zend.controller.actionhelpers.html >> I should be able to do this, but the above controller results in the >> error >> >> Fatal error: Uncaught exception 'Zend_View_Exception' with message >> 'script 'error/error.phtml' not found in path >> >> What am I missing? >> >> Thanks, >> Tim >