It looks like `Controller::render()` sets the body on the CakeResponse 
object and then returns the CakeResponse 
object: http://api.cakephp.org/2.6/source-class-Controller.html#922-962. I 
would imagine you could access the rendered view like so:
    public function test()
    {
        $this->render('/Emails/html/test', false);
        $emailBody = $this->response->body;
        // Do what you want with $emailBody here
    }



On Wednesday, February 4, 2015 at 5:33:35 PM UTC-5, BrendonKoz wrote:
>
> For various reasons I had decided to use a 3rd party email library within 
> my current CakePHP project. I thought that it might be nice to use 
> CakePHP's Views to create templating for my emails and take advantage of 
> layouts too. Unfortunately I'm stumped on just how to retrieve the rendered 
> output of a view back to the Controller method.
>
> I've tried the following:
>
>     public function test() {
>         $this->layout = false;
>         #$this->view = '/Emails/html/test.ctp';
>         $var = $this->render('/Emails/html/test', false);
>         pr($var->_body); die();
>     }
>
> $var->_body is protected (as denoted by the underscore). I saw no other 
> property within the $var variable that contained the "body" code within my 
> (template) view.
>
> Are there any ways to do this that I'm just not seeing? If so, can I 
> safely presume that layouts would be handled in a similar fashion?
>
> Thank you for any possible help...
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to