HowTo: Call method: renderPartial() - statically?
How can I call this method in Yii Framework:
$this->renderPartial(string $fileNameToRenderData, bool $wheaterToReturnOrEchoDirectly);
Statically, like this:
GodForbiddenClassName::renderP开发者_JS百科artial(string $fileNameToRenderData, bool $wheaterToReturnOrEchoDirectly);
You might want to look at renderInternal which I've used in custom class functions, etc. It can be called like:
$ccc = new CController('context');
$html = $ccc->renderInternal($view_file_string, array('data'=>$data), true);
i have to use render partial in model, i had code like this
public function sendEmail(){
$emailTemplate = new EmailTemplate();
$message = $emailTemplate->getEmailTemplate(EmailTemplate::AGENT_CONTACT_REFFER);
$message = $emailTemplate->replaceConstantWithValues($this->agent,$message);
$message = $emailTemplate->replaceConstantWithValues($this->contact,$message);
//$message = $emailTemplate->replaceConstantWithValues($this->contact->notes,$message);
$message = str_replace("[CONTACT_NOTES]", Yii::app()->controller->renderPartial('application.views.note._notes', array('notes'=>$this->contact->notes,'showLinks'=>false),true),$message);
$message = $emailTemplate->replaceConstantWithValues($this,$message);
$email = Yii::app()->email;
$email->from = $this->referringAgent->email;
$email->to = $this->agent->email;
$email->subject = "An agent has referred a contact to you";
$email->message = $message;
$email->send();
}
Here i have used Yii::app()->controller->renderPartial
It seems that this is impossible, since rendering is performed representations "on behalf" of the controller (or successor CBaseController)
But, in console application mode you can use this:
CConsoleCommand->renderFile()
See http://www.yiiframework.com/doc/api/1.1/CConsoleCommand
Check this yii wiki article written by me .. :)
====>>> $emailTemplate = $this->renderPartial('template/templatecontact',array(),true); //Getting email template content
精彩评论