Page 1 of 3

MJML

Posted: 14 Aug 2019, 11:46
by cnoelker
Hello,
I read this article: https://aimeos.org/tips/responsive-emai ... in-aimeos/
and installed mjml.

Afterwards, I copied the mjml-files from ai-client-html/client/html/templates/email to my extension directory.
I changed the mjml files, then started mjml to create php files. Works.

But when I run the order confirmation task in the TYPO3 planner, I get an error:
Call to a member function html() on null
client/html/templates/email/payment/html-body-standard.php line 5
$enc is not available.

When I run the task on the command line, there is no error message - but no emails, either.
typo3cms aimeos:jobs order/email/payment default

What configuration is necessary to make this work?
Claudia

Re: MJML

Posted: 15 Aug 2019, 05:56
by aimeos
No configuration necessary. You only have to make sure that you insert the PHP code before and after the MJML code in the generated HTML code again because MJML removes that.

Re: MJML

Posted: 15 Aug 2019, 07:14
by cnoelker
I think the origin of the problem is the generation of the php files from mjml.
According to the documentation, I ran:
npm install -l mjml
mjml html-body-standard.mjml -o html-body-standard.php

The resulting php file look much different from the php files which are provided by aimeos.

So, what's the correct way to generate these files?

Re: MJML

Posted: 15 Aug 2019, 16:27
by aimeos
We haven't tested that way yet because we create the PHP files in Visual Studio Code directly

Re: MJML

Posted: 15 Aug 2019, 16:55
by cnoelker
Oh! Then the article https://aimeos.org/tips/responsive-emai ... in-aimeos/ is really misleading, especially the last paragraph.
Do I get it right, that I don't need the MJML files at all, but should rather copy the PHP files and work on these and take care not to destroy the mjml syntax?

Re: MJML

Posted: 15 Aug 2019, 17:08
by aimeos
There are all options listed to generate HTML code from MJML syntax but we havn't tried all ourselves.

Nevertheless, the output is not as minimized the the distributed one but seems to be the same when running the NPM command:

Code: Select all

mjml html-body-standard.mjml -o html-body-standard.php

The PHP files contains the HTML code generated by MJML which is a) rather ugly and b) hard to extend by hand. So the best option is still to copy the MJML files (there's also a shared file here: https://github.com/aimeos/ai-client-htm ... ail/common), modify the copied MJML files and generate the PHP files you want to replace (add the PHP code before and after the MJML syntax again in the generated files).

Re: MJML

Posted: 18 Aug 2019, 09:00
by cnoelker
I created a script which does the tedious task for me:

Code: Select all

#!/bin/bash
# run mjml on the content within the mjml tags

# split before the starting tag
# after this, start0 contains the starting php
csplit -n 1 -sf start -z html-body-standard.mjml /\<mjml\>/ {*}

# split after the ending tag
# end0 is the mjml part, end1 is the ending php
csplit -n1 -sf end -z start1 /\<\/mjml\>/+1 {*}

# now run mjml
mjml end0 --config.minify -o mjml

# concatenate the bits and pieces
cat start0 mjml end1 > html-body-standard.php

# tidy up
rm start* end* mjml

Re: MJML

Posted: 18 Aug 2019, 10:08
by cnoelker
There is still one point open:

Why does it work if I start the scheduler task in TYPO3 backend, but no mails are send if I start it from the command line:
./typo3cms aimeos:jobs order/email/payment default

Re: MJML

Posted: 18 Aug 2019, 16:17
by aimeos
There are probaby some settings missing (detail page ID, etc.) if you use it that way. Recommendation is to configure a scheduler task and run that using ./typo3/cli_dispatch.phpsh or ./vendor/bin/typo3 scheduler:run

Re: MJML

Posted: 19 Aug 2019, 08:43
by cnoelker
I have actions/scripts which I want to run directly before/after sending the payment mails. The TYPO3 scheduler is too coarse for this.
Which settings are necessary? It would be great, if the aimeos job would notify the user if something is missing...
Or to provide a debug option which e.g. outputs the SQLs used or the recipients of the mails.