douyalin2258
2014-03-24 17:45
浏览 30
已采纳

如何在ZF2中将视图渲染为变量?

In a class file, I am trying to render a .phtml file into a variable and pass the HTML output of that .phtml file to a variable in another ViewModel. How do I do this in ZF2?

The code I have so far is, which doesn't really seem to work:

$layout = new ViewModel();
$layout->setTemplate('myPhtmlFile.phtml');
$layout->setTerminal(true);

$viewModel = new ViewModel();
$viewModel->setVariable('formBody', $layout);
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题