Good day!
I work with CI. I want to send a template email message, which should contain some variables. Now I have the following mysql table with email template:
ID | Title | Message | ---------------------- 1 | Тема | Текст | I call this template in the controller of the change in the status of a customer order on the site:
$user = $this->users_model->get_user_mail($verification['user']); $email_template = $this->emailtemplate_model->get_email_template(1); $this -> email -> from($this->settings->site_email, $this->settings->site_name); $this -> email -> to($user['email']); $this -> email -> subject($email_template['title']); $this -> email -> message("$email_template['message']"); Model file:
function get_email_template($id = NULL) { if ($id) { $sql = " SELECT * FROM {$this->_db} WHERE id = " . $this->db->escape($id) . " "; $query = $this->db->query($sql); if ($query->num_rows()) { return $query->row_array(); } } return FALSE; } Question: how to transfer the $ verification ['user'] variable to the letter template using conditional abbreviations in the pattern of the type "[NAME]", which would end up in Text "[NAME]", where "[NAME]" is the passed variable $ verification ['user']?
Newbie Grateful for any help!
str_replaceenough? - u_mulder