7

The ckeditor has the habit to escape characters like quotes or umlauts. This breaks the smarty-syntax when generating PDFs or mails. Is there a good work-around or solution?

3 Answers 3

10

Go to Administer menu » Customize Data and Screens » Display Preferences, click the Configure CKEditor button and add entities = false in the advanced options (see screenshot).enter image description here

Note: This is the default in CiviCRM 5.61+.

keywords: quotation marks, double quotes

4
  • 1
    Yes - you can do it in the Administer>>Customize Data and Screens>>Display Preferences>>Configure CKEditor button: solved the Smarty errors, but revealed something else, but I expect that is my error!
    – Mick Kahn
    Oct 17, 2017 at 11:07
  • @MickKahn What did you change in the configuration to solve the smarty errors?
    – Yossi
    Jan 4, 2018 at 7:02
  • Hmm... can't now remember exactly what my issue was or what I did. I may just have been giving details of how you configure ckeditor in CiviCRM 4.7 onwards. It looks as if I only found a partial solution anyway. The only additional config I have is entities (Boolean) (whether to use HTML entities in the editor output) set to "false". Sorry to be vague.
    – Mick Kahn
    Jan 5, 2018 at 7:54
  • This is much more important in Civi 5.43+ because of the use of quotation marks with the crmDate filter. Nov 10, 2021 at 18:43
2

A much simpler solution is to keep the portion of your smarty code that has quotes into HTML comments, so that the quotes won't be escaped:

<!-- {capture assign=genre}{contact.gender}{/capture}
{if $genre == "F"}{assign var='salutation' value='Chère'}
{else}
{assign var='salutation' value='Cher'}{/if} 
 --> 
<p>Chers parents, {$salutation} {contact.first_name},</p>
1
  • I am sorry: this doesn't work for me. Aug 19, 2021 at 10:24
1

For anyone looking for how to do this in Configure CKEditor, the setting you need is /civicrm/admin/ckeditor and set entities = false under advanced options.

1
  • I have this configuration in CKEditor but with CiviCRM 5.65.2 and 5.67.1 (WordPress) the problem still exists: go to civicrm/admin/messageTemplates, edit a template and add some Smarty code with quote or double quotes. If you switch from and to "source code" you will see "&quot;"
    – masetto
    Nov 21, 2023 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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