我是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等。我是否正确的方式或事情有什么我应该做的吗?