This topic is locked

smarty vs xt class

10/10/2008 4:35:48 PM
PHPRunner General questions
W
wblumstengel author

I have a project running PHPRunner v4.2 that utilizes the $smarty->fetch function to load a template and send it as the body of an email message. The snippet of code that accomplished this was:

mail($emailto, $emailsubject, $smarty->fetch('new_CR.htm'), $headers );


This worked great, resulting in an email being sent to the recipient specified by $emailto, with the body of the email message containing the correctly formatted html, as specified by the 'new_CR.htm' template.
I am now in the process of upgrading my project to v5.0, which utilizes the $xt class. I thought it would be a simple matter of substituting an equivalent XT function to get the template to insert into the body of the email message. I've tried different functions, including the following, but I cannot get the template to populate the body of the email message. The $xt->display function only causes the template to display on the browser page. The email message gets sent, but the body of the email is blank.

mail($emailto, $emailsubject, $xt->display('new_CR.htm'), $headers );


Any ideas?

Sergey Kornilov admin 10/11/2008

Here is what you can do in version 5.0:

ob_start();

$xt->display('new_CR.htm')

$result = ob_get_clean();

mail($emailto, $emailsubject, $result, $headers );
W
wblumstengel author 10/14/2008

Here is what you can do in version 5.0:


ob_start();

$xt->display('new_CR.htm')

$result = ob_get_clean();

mail($emailto, $emailsubject, $result, $headers );


Thanks You! Worked perfectly.

M
michaelmac 10/16/2008

Hey Sergey,
Where would I place that snippet of code for it work for a project I will be working on that has to handle emails.
Thanks
Mike

Sergey Kornilov admin 10/16/2008

Mike,
place it wherever you need to send an email.