Zend framework2 ZF2视图渲染
在ZF1中,我可以执行以下操作:Zend framework2 ZF2视图渲染,zend-framework2,Zend Framework2,在ZF1中,我可以执行以下操作: $view = new Zend_View(); $view->setScriptPath($viewDir); $html = $view->render('template_name.phtml'); 我如何在ZF2中做到这一点 public function abcAction() { $view = new ViewModel(array('variable'=>$value)); $view->setTempl
$view = new Zend_View();
$view->setScriptPath($viewDir);
$html = $view->render('template_name.phtml');
我如何在ZF2中做到这一点
public function abcAction()
{
$view = new ViewModel(array('variable'=>$value));
$view->setTemplate('module/controler/action.phtml'); // path to phtml file under view folder
return $view;
}
public function differentViewScriptAction()
{
// Use a different view script
$viewModel = new ViewModel();
$viewModel->setTemplate('application/view/arbitrary');
return $viewModel;
}
感谢您几乎涵盖了所有场景