0

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:

<p>Your membership expires on:{capture assign=mem_end_date}{membership.end_date}{/capture} {$mem_end_date|date_format:"%d %B %Y"}</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' 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.

   <p>Your membership expires on:{capture assign=mem_end_date}{membership.end_date}{/capture} {$mem_end_date|date_format:&quot;%d %B %Y&quot;}</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 source before opening the template?

This is a Drupal7/CiviCRMv4.4.16 site.

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.)

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.