Interesting. Is there a way to solve it on one place. What is enough for me is to prevent logging errors in error controller. So custom exception thrown from controller plugin is fine...if ajax action is called without ajax.
Regards, Saša Stamenković On Tue, Mar 23, 2010 at 5:43 PM, Hector Virgen <[email protected]> wrote: > The AjaxContext helper, in my opinion, is used to enhance an existing page > with Ajax functionality. That means your page would be accessible normally > without javascript, and then enhanced when javascript is available. > > If your action is coded to be Ajax-only, and somehow a user requests that > page without Ajax, then it seems proper that an error of some type should be > thrown. You could create a new exception for this case, and throw it within > your action if the page is requested without Ajax: > > public function facebookAction() > { > if (null === $this->_helper->ajaxContext->getContext()) { > throw new AjaxRequiredException('Ajax is required to view this > page'); > } > } > > You could then test for this in your ErrorController and show a helpful > error message to the user. > > Another option would be to create a facebook.phtml file that shows the > helpful error message. > > -- > Hector > > > On Tue, Mar 23, 2010 at 5:50 AM, umpirsky <[email protected]> wrote: > >> >> In init method of my controller I have >> >> public function init() { >> $this->_helper->ajaxContext >> ->setActionContext('facebook', 'html') >> ->setActionContext('twitter', 'html') >> ->initContext(); >> } >> >> This loads facebook and twitter widgets via ajax. They are in >> facebook.ajax.phtml and twitter.ajax.phtml and this works ok. But, very >> often I see in my error logs >> >> 2010-03-23T00:15:00+01:00 ERR (3): exception 'Zend_View_Exception' with >> message 'script 'index/facebook.phtml' not found in path >> (application/modules/default/views/scripts/)' in >> Zend/View/Abstract.php:976 >> Stack trace: >> #0 Zend/View/Abstract.php(876): >> Zend_View_Abstract->_script('index/facebook....') >> #1 Zend/Controller/Action/Helper/ViewRenderer.php(897): >> Zend_View_Abstract->render('index/facebook....') >> #2 Zend/Controller/Action/Helper/ViewRenderer.php(918): >> >> Zend_Controller_Action_Helper_ViewRenderer->renderScript('index/facebook....', >> NULL) >> #3 Zend/Controller/Action/Helper/ViewRenderer.php(957): >> Zend_Controller_Action_Helper_ViewRenderer->render() >> #4 Zend/Controller/Action/HelperBroker.php(277): >> Zend_Controller_Action_Helper_ViewRenderer->postDispatch() >> #5 Zend/Controller/Action.php(523): >> Zend_Controller_Action_HelperBroker->notifyPostDispatch() >> #6 Zend/Controller/Dispatcher/Standard.php(289): >> Zend_Controller_Action->dispatch('facebookAction') >> #7 Zend/Controller/Front.php(954): >> >> Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), >> Object(Zend_Controller_Response_Http)) >> #8 Zend/Application/Bootstrap/Bootstrap.php(97): >> Zend_Controller_Front->dispatch() >> #9 Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() >> #10 public_html/index.php(24): Zend_Application->run() >> #11 {main} >> >> I assume that for some reason (may be disabled javascript or direct url >> visit) request goes not from ajax, but full page request without ajax >> headers and /format/html. >> >> How can I fix to show just widget content, and skipp this error? >> -- >> View this message in context: >> http://n4.nabble.com/Help-with-ajaxContext-helper-tp1679001p1679001.html >> Sent from the Zend Framework mailing list archive at Nabble.com. >> > >
