CodeIgniter Forums
Parse Email Templates - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Parse Email Templates (/showthread.php?tid=2909)



Parse Email Templates - El Forum - 08-30-2007

[eluser]Unknown[/eluser]
Has anyone developed a email template helper.

Ideally it would an email template e.g.

Dear {name},

You new username and password are:

{username}
{password}

Regards,

Admin

--

And would swap out the {variables} for supplied ones.

Cheers,

Chris.


Parse Email Templates - El Forum - 08-30-2007

[eluser]jkevinburton[/eluser]
thats actually quite easy.

create your template file somewhere in your views...
do a:
Code:
$items = array("name"=>"Kevin", "message"=>"What ever you want here....");
$emailTMP = $this->load->view('path/to/email/html', $items, TRUE);
instead of {name} you would just put <?=$name?>
by putting the optional TRUE in the 3rd parameter you are actually returning the result of that view to the variable: $emailTMP

OR To do it your way:
Code:
$emailTMP = $this->load->view(('path/to/email/html', array(), TRUE);
str_replace("{name}", "kevin", $emailTMP);
and so on for all your variables...


hope that helps!