enigmadigital / Formerly

Plugin to allow users to create custom forms within Craft CMS
MIT License
59 stars 24 forks source link

Date formatting notifications #71

Closed cole007 closed 8 years ago

cole007 commented 8 years ago

Is there any way to control the formatting of dates sent by email? Defaulting to YYYY-MM-DD in notifications despite the formatting set for the locale.

wiso1234 commented 8 years ago

Hi Cole,

The email template is essentially a twig template and we use the craft rendering engine to produce the email body.

See line 253 of https://github.com/xodigital/Formerly/blob/master/services/Formerly_SubmissionsService.php

So I think this means you can add twig filters to your email copy so something like { myDate|date('jS F Y') }.

Give it a go and let us know if it works

regards

Andrew

On 10 May 2016 at 21:10, Cole Henley notifications@github.com wrote:

Is there any way to control the formatting of dates sent by email? Defaulting to YYYY-MM-DD in notifications despite the formatting set for the locale.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/xodigital/Formerly/issues/71

wiso1234 commented 8 years ago

oh actually no that won't work :(

We go through every tag on the mail template and confirm the tagname is valid. This was to ensure that we didn't get runtime errors on the site when trying to send the email (craft would throw a really obscure error that was confusing everyone).

So it matches the text between the braces to confirm that is a valid tagname

preg_match_all('/{([^}]*)}/', $template, $matches);

We should enhance that to allow for filters in tag,

On 11 May 2016 at 10:34, andrew wisener wisenerandrew@gmail.com wrote:

Hi Cole,

The email template is essentially a twig template and we use the craft rendering engine to produce the email body.

See line 253 of https://github.com/xodigital/Formerly/blob/master/services/Formerly_SubmissionsService.php

So I think this means you can add twig filters to your email copy so something like { myDate|date('jS F Y') }.

Give it a go and let us know if it works

regards

Andrew

On 10 May 2016 at 21:10, Cole Henley notifications@github.com wrote:

Is there any way to control the formatting of dates sent by email? Defaulting to YYYY-MM-DD in notifications despite the formatting set for the locale.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/xodigital/Formerly/issues/71

wiso1234 commented 8 years ago

I've fixed the template filtering code to allow twig filters to be used. So now you can add twig filters to format dates