db->from('email'); $this->db->where('slug',$slug,TRUE); $template=$this->db->get()->row(); if(!$template) { return FALSE; } $tags_raw=$template->tag; $tags=explode(',',$tags_raw); $template->subject=$this->inject_substitute($template->subject,$tags,$data); $html = $template->email_header . $template->html . $template->email_footer; $template->html = $this->inject_substitute($html, $tags, $data); return $template; } public function inject_substitute($raw, $tags, $data) { foreach ($data as $key => $value) { if (in_array($key, $tags) || $key == 'logo') { if ($key == 'logo') { $logo = base_url('assets/frontend/img/logo.png'); $new_val = ""; $value = $new_val; } $raw = str_replace('{{{' . $key . '}}}', $value, $raw); } } return $raw; } }