×

Welcome to TagMyCode

Please login or create account to add a snippet.
1
0
 
0
Language: PHP
Posted by: Alessandro Pietrobelli
Added: Dec 1, 2011 9:21 AM
Modified: Dec 1, 2011 9:30 AM
Views: 67
http://www.icod3.com/2011/11/30/cambiare-il-context-di-output-nelle-action-dei-controller-in-zend-framewor/
  1. class App_NameController extends Zend_Controller_Action
  2. {
  3.     public function init()
  4.     {
  5.          // CHANGE CONTEXT ON ACTION FRUIT
  6.          $contextSwitch = $this->_helper->getHelper('contextSwitch')
  7.                                         ->addActionContext('fruit', 'json')
  8.                                         ->initContext();
  9.     }
  10.  
  11.     public function indexAction()
  12.     {
  13.           //DEFAULT HTML CONTEXT OUTPUT
  14.     }
  15.  
  16.     public function fruitAction()
  17.     {
  18.          $result = array('pear', 'apple', 'strawberry', 'banana'):
  19.  
  20.          //JSON CONTEXT OUTPUT
  21.          $this->_helper->json($result);
  22.     }
  23. }