responsiv / campaign-plugin

[PREMIUM] Send professional campaign messages to your subscribers.
http://octobercms.com/plugin/responsiv-campaign
5 stars 2 forks source link

Can I use a beforeSave method? #50

Closed smartscripts-nl closed 2 years ago

smartscripts-nl commented 6 years ago

My customer has the habit of sometimes typing multiple spaces between words. In the resulting email that looks very ugly.

So I would like to have a method like beforeSave(), that would enable me to manipulate the HTML before it is being saved. Or does such a method already exist? If so, how can I call it?

daftspunk commented 2 years ago

Yes, you can hook in to the Message model's beforeSave event

Model::extend(function ($model) {
    $model->bindEvent('model.beforeSave', function () use ($model) {
        $model->content_html = processHtml($model->content_html);
    });
});