我在创建电子邮件时使用CKEditor 4来替换它。消息主要是商业信函模板。我想替换数据库中的字母模板值中的某些部分。
在搜索CKEditor网站时,我发现了这个placeholder plugin。我知道如何将插件添加到我的CKEditor中。 BUt我想知道如何设置这个占位符来自我的php变量的值。此变量保存数据库字段列内容,例如$ first_name。
我搜索过任何类似的问题,但他们通常会跳过我正在寻找的部分。
非常感谢任何建议
谢谢你。
答案 0 :(得分:2)
当您将CKEditor与占位符插件一起使用时,您可能会在数据库中保存一个text / html电子邮件模板,例如
Dear {f_name},
You owe us {money} Euros.
标记{f_name}
和{money}
是示例,可以是您想要的占位符。
当您为每封发送的电子邮件填充文本时,您可以创建如下函数:
$email['body'] = $this->emails_model->fetch_your_email_body();
foreach ($users as $user){
$email['body'] = str_replace('{f_name}', $user['first_name'], $email['body'] );
$email['body'] = str_replace('{money}', $user['amount_to_pay'], $email['body']);
$this->email->message($email['body']);
$this->email->send()// send your email to each user (with or w/o the CI email class)
}
这将为您的$ users数组中的每个用户发送个性化电子邮件。