我是Zend的新手,我正在開發一個需要三個上下文來執行特定操作的項目。通常會使用標準上下文,用於AJAX調用的AJAX上下文,以及最後的打印友好上下文。我們的目標是爲每個那些有自己的看法,所以使用的視圖文件將是這樣的:Zend中的多個操作上下文
/action_name.phtml /action_name.ajax.phtml /action_name.print.phtml
我閱讀http://framework.zend.com/manual/en/zend.controller.actionhelpers.html並想出了:
public function init()
{
// add any necessary context switching here
$contextSwitch = $this->_helper->getHelper('AjaxContext');
$contextSwitch->addActionContext('history', 'html')
->initContext();
//need to add another context for the print view
$this->_helper->getHelper('contextSwitch')->addActionContext('history','print')->initContext();
}
前兩行我深信作品,但我不知道如果我要對打印上下文正確的方式,因爲在示例中的第二個參數通常是一個文件類型,如JSON,XML,HTML等。我是否正確的方式或事情有什麼我應該做的嗎?