开发者

Zend_View helpers not availble when manually calling $view->render(): how to fix it?

I recently discovered that view helpers seem to be unavailable when manually calling $view->render().

In this particular case, I've got a config view helper which I can easily call from within my view scripts like so:

$this->config()->some->param

I am now trying to send a mail and discover that the above does not seem to work when manually calling the render method:

/** 
 * 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'));

Am I overlooking something? Is this a bug or intended behavi开发者_如何学运维our? Should I take another approach on manually rendering view scripts?

Thanks in advance.


Can we see a bit more code?

So far I've got this to work with manually rendered views.

$view->setHelperPath('/path/to/helper/class');
print $view->render('view.phtml');

This here is the class named FooBar.php within /path/to/helper/class

<?php
class Zend_View_Helper_FooBar extends Zend_View_Helper_Abstract {
    public function fooBar()
    {
        return 'random string this will be the output';
    }
}

Within view.pthml

print $this->fooBar();

Outputs

random string this will be the output

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜