Php 手动调用$View->;时,Zend_视图帮助程序不可用;render():如何修复它?
我最近发现,手动调用Php 手动调用$View->;时,Zend_视图帮助程序不可用;render():如何修复它?,php,zend-framework,Php,Zend Framework,我最近发现,手动调用$view->render()时,该选项似乎不可用 在这种情况下,我有一个配置视图助手,我可以从视图脚本中轻松调用它,如下所示: $this->config()->some->param 我现在正试图发送一封邮件,发现手动调用render方法时上述操作似乎不起作用: /** * Within these view scripts, $this->config() is called, * which results in an empty o
$view->render()
时,该选项似乎不可用
在这种情况下,我有一个配置视图助手,我可以从视图脚本中轻松调用它,如下所示:
$this->config()->some->param
我现在正试图发送一封邮件,发现手动调用render方法时上述操作似乎不起作用:
/**
* Within these view scripts, $this->config() is called,
* which results in an empty object
*/
$mail->setBodyText($this->view->render('partials/invite/email/text.phtml'));
$mail->setBodyHtml($this->view->render('partials/invite/email/html.phtml'));
我是否忽略了什么?这是错误还是预期行为?我是否应该采取另一种手动呈现视图脚本的方法?
提前谢谢。我们能再看一点代码吗 到目前为止,我已经将其用于手动渲染视图
$view->setHelperPath('/path/to/helper/class');
print $view->render('view.phtml');
这是/path/to/helper/class中名为FooBar.php的类
<?php
class Zend_View_Helper_FooBar extends Zend_View_Helper_Abstract {
public function fooBar()
{
return 'random string this will be the output';
}
}
输出
随机字符串这将是输出
手动提供助手路径也可以为我提供帮助。不过,我还是觉得这很麻烦。助手路径是通过我的应用程序配置文件注册的,应该已经设置好了。如果已经有助手路径,那么您的助手类必须放在该路径中。它在那里并且不工作吗?谢谢你的回复,但是助手路径注册正确。当渲染视图而不实际调用$this->view->render()时,它们执行得很好,这让人困惑。在控制器中手动调用$this->view->render()似乎会破坏视图帮助程序。我注意到了这个有线问题,我曾经在配置resources.view.helperPath.dagho_view_helper=“dagho/view/helper”中添加helper,但在上次更新后,某些内容发生了更改,我无法修复,直到我在配置中添加initHelper()函数以正确映射它,我才同意Aron的wiredYa最有可能是bug,对此无能为力。
print $this->fooBar();