Home > Zend Framework > Cambiare il Context di output nelle Action dei Controller in Zend Framework

Cambiare il Context di output nelle Action dei Controller in Zend Framework

class App_NameController extends Zend_Controller_Action
{
    public function init()
    {
         // CAMBIA IL CONTEXT IN JSON NELL'AZIONE SEARCH
         $contextSwitch = $this->_helper->getHelper('contextSwitch')
				        ->addActionContext('fruit', 'json')
					->initContext();
    }
 
    public function indexAction()
    {
          //RESTITUISCE QUALCOSA IN CONTEXT NORMALE HTML
    }
 
    public function fruitAction()
    {
         $result = array('pera', 'mela', 'fragola', 'banana'):
 
         //RESTITUISCO IL DATO IN FORMATO JSON
         $this->_helper->json($result);
    }
}
  1. Nessun commento ancora...
  1. Nessun trackback ancora...