0

I'm hoping to use email templates in Scheduled reminders that have css in a <style> tag at the start of the email. Declaring css here for html elements and classes makes MUCH more robust templates that aren't prone to disasters from click-happy admin teams deleting in-line styles.

I can use these templates effectively in CiviMail and when sending emails directly from a contact's summary screen.

However, the Scheduled reminders engine strips out all the css attributes in the initial <style> tag. So the email looks awful and the <style> declaration contains all the tags and classes - with no actual css!

I'm guessing this is perhaps something to do with the IDS? I don't see any IDS log errors though. If it is something that we can tell the IDS to ignore, I'd be grateful to know how to do this.

Or is there some other way we can tell the Scheduled reminder system not to strip those attributes?

I'm using 4.6.24 with Drupal 7.54 and CKEditor. Note that the styles aren't being stripped by CK Editor (I've adjusted the editor's config.js to make this possible), because they work perfectly well in CiviMail and from a contact's summary screen... and they are there safely inside the Scheduled reminder email CKEditor screen.

Perhaps it may be useful to add here that I'm not using a <head> tag to contain my <style> tag. In my config I haven't been able to persuade CKEDitor to retain the <head> tags. Nevertheless even so all is well for the other email scenarios.

One final point - I'm aware of how to skip IDS using the following method. So could possibly add an extra path to skip in this: https://github.com/teamsinger/uk.teamsinger.civicrm.mailgun#user-content-skip-ids-checks

Thanks for your help.

  • random thought, could be a red herring: might be worth checking whether there is any smarty processing stuff happening as that can strip out css stuff (as it looks similar to smarty tags) – michaelmcandrew Mar 12 '17 at 22:29
4

The main issue seems to be the <style> tag defined in the templates. Schedule Reminder uses smarty engine by default which strips down the css styles defined.

This doesn't occur in CiviMail because Smarty is disabled in civicrm.settings.php. If CIVICRM_MAIL_SMARTY is set to 1, civimail will too see this error.

As Smarty processing is done, escape the tag within {literal}. Something like:

{literal}
  <style>........</style>
{/literal}
.
.
.
(further html code)

See - http://www.smarty.net/docs/en/language.escaping.tpl.

To avoid the {literal} statements being displayed in the email's wysiwyg view you can enclose those {literal} statements in a <p> tag with class or style to make them hidden - eg <p style="display:none;">.

  • 1
    This is a brilliant solution. One tiny drawback is that the {literal} statements will be displayed in the email's wysiwyg view. So to further improve it, Jitendra suggested enclosing those {literal} statements in a <p> tag with class or style to make them hidden - eg <p style="display:none;">. – Andyg8 Mar 30 '17 at 14:39
  • 1
    i added that to the answer itself – petednz - fuzion Apr 1 '17 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.