5

我正在使用 Zend 框架。

我有一个名为“UserController”的控制器,它有一个公共函数 displayAction()。

我想知道如何让该操作方法使用与默认 display.phtml 不同的查看器。

任何帮助表示赞赏。

4

2 回答 2

17

您可以使用

$this->render('actionName');

或者,您可以通过调用直接调用视图脚本

$this->renderScript('path/to/viewscript.phtml');

有关更多信息,您可以查看http://framework.zend.com/manual/en/zend.controller.actionhelpers.html,特别是关于render()renderScript()方法的部分。

于 2008-11-12T12:23:04.480 回答
1

最近,我在使用上述方法时遇到了错误(使用 ZF 1.11.11)。我在这方面取得了成功:

$this->_helper->viewRenderer('action');
于 2012-05-06T08:25:43.973 回答