Created
December 11, 2012 16:59
-
-
Save corleonis/4260280 to your computer and use it in GitHub Desktop.
Switch context with ZF - JSON/HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Bruegelbe_InfocusController extends Herder_Controller_Action | |
{ | |
public function init() { | |
$context = $this->_helper->contextSwitch(); | |
$context->addActionContext('contentItems', array('json')) | |
->initContext(); | |
} | |
public function contentItemsAction() { | |
$tables = Bruegel_Model_Infocus::getTables(); | |
$table = $this->_getParam('table'); | |
$class = $tables[$table]; | |
$model = new $class(); | |
$data = null; | |
if(isset($model) && is_object($model)) { | |
if($table =='tx_bruegel_people') { | |
$order ='name'; | |
} else { | |
$order ='title'; | |
} | |
$data = $model->getAll(array(), null, $order); | |
} | |
$this->view->data = Bruegel_Model_Infocus::buildArray($data); | |
if($this->_request->isXmlHttpRequest()) { | |
$this->_helper->contextSwitch()->initContext('json'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment