可以';t从控制器[Zend Framework]中调用的另一个视图访问View Helper


Can't access to View Helper from another view called in a controller [Zend Framework]

我需要在IndexController内通过Zend_Mail发送电子邮件。与其在变量中设置电子邮件正文,我宁愿使用另一个视图。以下是我如何在控制器中调用我的视图:

    $view = new Zend_View();
    $view->addScriptPath(APPLICATION_PATH.$this->getRequest()->getModuleName().DS.'views'.DS.'scripts'.DS.'email')
         ->setHelperPath(LIB_PATH.'Ms'.DS.'View'.DS.'Helper');
    $view->subscription = $subscription;

然后我配置电子邮件并像这样发送:

    $mail = new Zend_Mail('UTF-8');
    $mail-> // ...
         ->setBodyHtml($view->render('checkout.phtml'))
         ->send();

scripts/email/checkout.phtml中,我使用了两个视图辅助对象,当在控制器的默认视图中调用时,它们工作得非常好。但在checkout.phtml中使用时不再如此。

我同时使用了$this->price($myTotal)$this->getHelper('Price')->price($myTotal),但它们都不起作用。

我得到的错误是:Plugin by name 'Price' was not found in the registry; used paths: Zend_View_Helper_: Zend/View/Helper/;C:'wamp2.4'www'abo'library'Ms'View'Helper/。最奇怪的是,它在正确的目录中寻找助手,却找不到

有什么想法吗?

非常感谢!

我不得不通过添加第二个参数来设置助手路径,如下所示:

$view = new Zend_View();
$view->setHelperPath(LIB_PATH.'Ms'.DS.'View'.DS.'Helper', 'Ms_View_Helper');