Welcome Guest, Not a member yet? Register   Sign In
Parse Email Templates
#1

[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.
#2

[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!




Theme © iAndrew 2016 - Forum software by © MyBB