I can call partial method from a view object. However, I need to call it from a model class (which is standalone). I need to render a xhtml piece (with code) and parse the result and it happens inside a model class.
Is it possibl开发者_如何转开发e?
yeah, but usually views shouldn't be generated by the models directly. Any interaction with the views should be done by the controllers.
Here's a code snippet to use Zend_View as a standalone:
$view = new Zend_View;
$view->setBasePath(APPLICATION_PATH . '/modules/blog/views/');
$view->subject = $subject;
$htmlMessage = $view->render('emails/template.phtml');
You should be able to access your view object, and subsequently partial view helper, in a model as follows:
$view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
$view->partial(/*usual parameters here*/);
精彩评论