Answers.Body: <p>You can stop ckeditor encoding quotes by editing ckeditor.js in /packages/ckeditor. There's a push command that begins 'quot,iexcl,cent,pound,curren,yen' - remove quot from this list. This isn't terribly elegant, and would obviously need doing on every upgrade, but I couldn't find anything equivalent in the ckeditor config files without disabling all html entities entirely.</p>
  
  <p>Alternatively, if you don't need to use visual editor at all, you could separate the two entirely. Copy the content from the template into a .tpl file and put it in the templates directory somewhere (or in the templates folder in an extension). Then include in the visual editor with:</p>
  
  <p>{include file=CRM/membership.tpl} (or as appropriate)</p>
  
  <p>Then edit this file directly in whatever way suits. </p>
  
  <p>(We had odd problems with the presence/non-presence of the $ sign in smarty tags when we included files like this, but that was a few versions ago so that bug may have been fixed by now.)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-05T09:35:51.953Z
Answers.LastActivityDate: 2015-08-05T09:35:51.953Z
Answers.UserDisplayName: Andrew West
Body: <p>I have a message template that we use to print letters for those joining our association. We want to include the end date for their memberships in the letter (This used to be printed on membership cards, but we have ditched them.)</p>
  
  <p>If I search for the new members and display the results as memberships, I can include the token {membership.end_date} in the letter but it displays as, say, 2016-12-27 which is not commonly seen in Australia.</p>
  
  <p>Our site settings include <strong>define( 'CIVICRM_MAIL_SMARTY', 1 );</strong> so the following code gives the formating I actually want: </p>
  
  <pre><code>&lt;p&gt;Your membership expires on:{capture assign=mem_end_date}{membership.end_date}{/capture} {$mem_end_date|date_format:"%d %B %Y"}&lt;/p&gt;
  </code></pre>
  
  <p>Unfortunately this is somewhat temperamental.  If I save the template when it is displaying the code and the next time I open it I select 'Source'  <strong>before</strong> opening the template, then the formatting is correct.  </p>
  
  <p>However, if I save the template when it is displaying the code and then open the template before I select 'Source' the next time I use it, the <strong>"</strong> is changed to <strong>&quot;</strong> (see below) and I don't get any end date printed at all.</p>
  
  <pre><code>   &lt;p&gt;Your membership expires on:{capture assign=mem_end_date}{membership.end_date}{/capture} {$mem_end_date|date_format:&amp;quot;%d %B %Y&amp;quot;}&lt;/p&gt;
  </code></pre>
  
  <p>Is there some other way I can write things so that it will retain the formatting I want without the person who will be running the letters having to remember to select <strong>source</strong> before opening the template? </p>
  
  <p>This is a Drupal7/CiviCRMv4.4.16 site.  </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-29T22:18:36.190Z
Comments.Text: did you even find any good solutions to this?
Comments.UserDisplayName: Yossi
Tags: <message-templates><smarty>
Title: How can I preserve smarty date formating in message templates?
ThreadText: # How can I preserve smarty date formating in message templates?
  
  (Asked by: username_0 on 2015-08-05)
  
  I have a message template that we use to print letters for those joining our association. We want to include the end date for their memberships in the letter (This used to be printed on membership cards, but we have ditched them.)
  If I search for the new members and display the results as memberships, I can include the token {membership.end_date} in the letter but it displays as, say, 2016-12-27 which is not commonly seen in Australia.
  Our site settings include define( 'CIVICRM_MAIL_SMARTY', 1 ); so the following code gives the formating I actually want: 
  Your membership expires on:{capture assign=mem_end_date}{membership.end_date}{/capture} {$mem_end_date|date_format:"%d %B %Y"}
  
  Unfortunately this is somewhat temperamental.  If I save the template when it is displaying the code and the next time I open it I select 'Source'  before opening the template, then the formatting is correct.  
  However, if I save the template when it is displaying the code and then open the template before I select 'Source' the next time I use it, the " is changed to " (see below) and I don't get any end date printed at all.
     Your membership expires on:{capture assign=mem_end_date}{membership.end_date}{/capture} {$mem_end_date|date_format:"%d %B %Y"}
  
  Is there some other way I can write things so that it will retain the formatting I want without the person who will be running the letters having to remember to select source before opening the template? 
  This is a Drupal7/CiviCRMv4.4.16 site.
  
  **Tags:** message-templates, smarty
  
  > **Comments:**
  > **username_1**: did you even find any good solutions to this?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-08-05. Score: 1
  
  You can stop ckeditor encoding quotes by editing ckeditor.js in /packages/ckeditor. There's a push command that begins 'quot,iexcl,cent,pound,curren,yen' - remove quot from this list. This isn't terribly elegant, and would obviously need doing on every upgrade, but I couldn't find anything equivalent in the ckeditor config files without disabling all html entities entirely.
  
  Alternatively, if you don't need to use visual editor at all, you could separate the two entirely. Copy the content from the template into a .tpl file and put it in the templates directory somewhere (or in the templates folder in an extension). Then include in the visual editor with:
  
  {include file=CRM/membership.tpl} (or as appropriate)
  
  Then edit this file directly in whatever way suits.
  
  (We had odd problems with the presence/non-presence of the $ sign in smarty tags when we included files like this, but that was a few versions ago so that bug may have been fixed by now.)
  
  
  ---
  
  