Answer the question
In order to leave comments, you need to log in
Is it possible to write the result of the render method for a view into a variable (php, Yii framework)?
I need to send notification emails to users (letters are not text/plain, but text/html). I would like to have for each template letter, its own view (view) and do something like:
$body = $this->renderToString('hello_mail_view');
mail($email, $subject, $body, $headers);
Answer the question
In order to leave comments, you need to log in
I need to send notification emails to users (letters are not text/plain, but text/html). I would like to have for each template letter, its own view (view) and do something like:
Is there such a possibility?
Yes. To do this, you can use the renderPartial method with the return(true) parameter. The code will look like this:$body = Yii::app()->controller->renderPartial('hello_mail_view', array('param'=>'value'), true); mail($email, $subject, $body, $headers);
I recommend that you read the official documentation on the topic:
It's a perfectly normal solution. You can issue it as an extension.
I would recommend using existing extensions for sending mail than inventing your own "bicycle".
www.yiiframework.com/doc/api/1.1/CController#rende...
See what the third parameter does...
RenderPartial will work for you though.
www.yiiframework.com/doc/api/1.1/CController#rende...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question