In ZF1 I can do something like this:
$view = new Zend_View();
$view->setScriptPath($viewDir);
$html = $view->render('template_name.phtml');
How can I do that in ZF2?
In ZF1 I can do something like this:
$view = new Zend_View();
$view->setScriptPath($viewDir);
$html = $view->render('template_name.phtml');
How can I do that in 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;
}
Thanks to akrabat for covering almost every scenario.