Adding Today's Date to an Email Template & Customize it

Get your CiviCRM questions answered here!

Adding Today's Date to an Email Template & Customize it

Postby Conrad » Mon Jul 11, 2011 2:55 pm

Hello All,

To add today's date to an email template, you need to insert the token:

{$smarty.now|date_format}

It works just like {contact.first_name} or any other token in CiviCRM, except it doesn't give 'first name', it gives today's date. But you already figured that out...

The date token is not on the 'Insert Tokens' list, you have to manually insert the token into your email template. After that, every time you fire up an email from your tokenized template, today's date will be automatically filled in at the location of the token.

Cheers,
Conrad
Conrad
Site Admin
 
Posts: 54
Joined: Tue Feb 15, 2011 4:20 pm
Location: GingerFeet LLC
 

Re: Adding Today's Date to an Email Template

Postby anne » Wed Aug 31, 2011 10:22 am

Conrad,
Can we change it so that the complete month is spelled out. ie July instead of Jul. I am using this token in snail mail templates too.
Thanks
anne
 
Posts: 7
Joined: Fri Mar 18, 2011 9:56 am
 

Re: Adding Today's Date to an Email Template

Postby Conrad » Wed Aug 31, 2011 11:39 am

Hi Anne,

I believe you can.

This page explains in great detail:
http://www.smarty.net/docs/en/language. ... format.tpl

Basically instead of:
{$smarty.now|date_format}

You write:
{$smarty.now|date_format:"A bunch of stuff"}

Where "A bunch of stuff" is a series of percent signs and letters (explained on the page above--"date_format conversion specifiers") which can be separated by spaces, commas and spaces, etc.

Cheers,
Conrad
Conrad
Site Admin
 
Posts: 54
Joined: Tue Feb 15, 2011 4:20 pm
Location: GingerFeet LLC
 

Re: Adding Today's Date to an Email Template & Customize it

Postby anne » Fri Sep 23, 2011 7:13 am

I tried to add the date to a pdf using the following:
{$smarty.now|date_format: "%B,%d,%G"}
It returned no date. Where did I go wrong?
anne
 
Posts: 7
Joined: Fri Mar 18, 2011 9:56 am
 

Re: Adding Today's Date to an Email Template & Customize it

Postby Deb McGinley » Tue Feb 07, 2012 1:08 pm

I'd also like to see the month spelled out.

I tried using {$smarty.now|date_format: "%A, %B %e, %Y"} in a Message Template and nothing shows.

Where did I go wrong?

Deb McGinley
HFH of Greater Centre County
Bellefonte, PA 16823
(814) 353-2390
Deb McGinley
 
Posts: 90
Joined: Thu Feb 24, 2011 2:50 pm
 

Re: Adding Today's Date to an Email Template & Customize it

Postby Madelynn » Tue Feb 07, 2012 1:42 pm

Hi Deb,

The syntax is correct. Is the message template for printing PDF letters? Is this where the date is not showing up? If so, this could be related to a problem we're having with a utility in CiviCRM called DOMpdf. We're still in the process of trying to correct the issues.

Will keep you informed on our progress.

Best,
Madelynn
Madelynn
Site Admin
 
Posts: 138
Joined: Wed Feb 16, 2011 8:37 pm
Location: GingerFeet LLC
 

Re: Adding Today's Date to an Email Template & Customize it

Postby Deb McGinley » Wed Feb 08, 2012 6:34 am

Hi Madelynn,

Yes, it's with PDF letter templates.

Deb
Deb McGinley
 
Posts: 90
Joined: Thu Feb 24, 2011 2:50 pm
 

Re: Adding Today's Date to an Email Template & Customize it

Postby Madelynn » Wed Feb 08, 2012 11:23 am

Thanks, Deb.

I think this is related to the DOMpdf and we're working to try and resolve it.
Sorry for the inconvenience.

Madelynn
Madelynn
Site Admin
 
Posts: 138
Joined: Wed Feb 16, 2011 8:37 pm
Location: GingerFeet LLC
 

Re: Adding Today's Date to an Email Template & Customize it

Postby Deb McGinley » Mon Nov 12, 2012 12:48 pm

I've been tinkering with the date token for my message templates and can't get past {$smarty.now|date_format}. I've tried referencing Smarty (per Conrad's earlier posting) and using {$smarty.now|date_format: "%B %d, %Y"}, {$smarty.now|date_format: "%x"} and other combinations without any luck. I think the Smarty link is more for programmers than for we simple folks. :oops:

I just want to change Nov 12, 2012 to read November 12, 2012 in my templates. Specific instructions would be greatly appreciated.

Deb McGinley
Office Manager
Habitat for Humanity of Greater Centre County
Bellefonte, PA
Deb McGinley
 
Posts: 90
Joined: Thu Feb 24, 2011 2:50 pm
 

Re: Adding Today's Date to an Email Template & Customize it

Postby Madelynn » Tue Nov 13, 2012 9:49 am

OK. This is a bit tricky. The problem with CCRM's Smarty tokens is that when you input them in using the CKEditor, the editor is converting the quotes necessary for Smarty to work to plain text. You must create your Smarty tokens in Source view and save it while in that view and then Smarty should work -- You'd think "Smarty" would be smarter than that! :)

Here's how:

1. After completing your template in the normal WYSIWYG view, click on Source. It is the first button in the first row of buttons on CKEditor. Be prepared to see what may look like Greek (depending on your template). Hopefully, you will want the date to appear before everything else.

2. Add a paragraph or two above all the other code you see. Be sure not to disturb the additional code.

3. Type in your Smarty date in the format you want: {$smarty.now|date_format: "%B %d, %Y"} for example.

4. Save the template while still in Source view.

Note: you may have to perform the above steps every time you make a change to your template. Because saving the template with the CKEditor enabled will convert those quotes.

Best,
Madelynn
Madelynn
Site Admin
 
Posts: 138
Joined: Wed Feb 16, 2011 8:37 pm
Location: GingerFeet LLC
 
 
Next

Return to CiviCRM How To

Who is online

Users browsing this forum: No registered users and 1 guest

cron