You can do this: $this->view->assign($treeNodes->fetchAll()->toArray());
That will take each element of the array and assign them as view variables. -- Hector On Wed, May 12, 2010 at 12:23 AM, shahrzad <[email protected]>wrote: > > hi all, > > in index action , I fetch db data and with contextSwitch I convert it to > json file. it's ok But my problem is the format of json file is like this : > > {"treeNodes":[{"nid":"1","parentID":"0","text":"Dashboard","cls":"x-btn-icon","icon":"lib\/extjs\/resources\/images\/default\/icon\/Dashboard.png","singleClickExpand":"1","leaf":"0","id":"Dashboard"},{"nid":"2","parentID":"1","text":"Dashboard","cls":"firstExpanded","icon":"lib\/extjs\/resources\/images\/default\/tree\/s.gif","singleClickExpand":"1","leaf":"0","id":null},{"nid":"3","parentID":"2","text":"Dashboard","cls":"x-btn-icon","icon":"lib\/extjs\/resources\/images\/default\/tree\/s.gif"]} > > I need the contents of [], no the all.. it means that I need a function > like a['treeNodes'],.. remove the treeNodes the root.. > > > --------------------------------------- > class IndexController extends Zend_Controller_Action > { > > public function init() > { > $this->_helper->contextSwitch() > > ->addActionContext('index', 'json') > > ->setAutoJsonSerialization(true) > ->initContext(); > } > > public function indexAction() > { > $treeNodes = new Application_Model_DbTable_TreeNodes(); > $this->view->treeNodes = $treeNodes->fetchAll()->toArray(); > } > -- > View this message in context: > http://zend-framework-community.634137.n4.nabble.com/ContextSwitch-and-json-problem-tp2195683p2195683.html > Sent from the Zend Framework mailing list archive at Nabble.com. >
