Wednesday, February 4, 2015

Cake v2.x -- Looking to return rendered view to the Controller

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 cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: