Just looking at the API code I know that'll work. Ugh. Looking through all 
of the files yesterday I'm surprised I missed it. Thanks, Andrew!!!

On Tuesday, February 10, 2015 at 11:22:28 PM UTC-5, Andrew Lechowicz wrote:
>
> My bad. In typical Cake fashion, a method with the name of the property 
> you want to "get" when passed null returns that property. So my code above 
> should be 
> $emailBody = $this->response->body();
> Note the parentheses. For your reference: 
> http://api.cakephp.org/2.6/source-class-CakeResponse.html#605-617
>
> On Tuesday, February 10, 2015 at 7:44:55 PM UTC-5, BrendonKoz wrote:
>>
>> Thank you for the response, Andrew. In my test (using a view file that 
>> just contains static text), $this->response->body seemed to return an empty 
>> string due to ViewBlock->get having an empty $ViewBlock->_blocks value (as 
>> to what $_blocks is or how it's set, I've no idea).
>>
>> I don't suppose anyone has any other ideas?
>> I've tried switching to using CakeEmail for sending email to take 
>> advantage of layouts and views and there's a bug preventing me from 
>> connecting to my SMTP server's TLS connection (which I have to report), so 
>> neither solution is currently working for me. :-/ Getting templates to work 
>> with a third party library would be easier for me!
>>
>>
>>
>> On Thursday, February 5, 2015 at 4:14:48 PM UTC-5, Andrew Lechowicz wrote:
>>>
>>> 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