Hello Everybody
I'm sending a mail to the customer. Therefore I created a mail template which should contain a list. To create the list I now try to include a phtml which is not working. The mail is always sent whithout the phtml content. (also if i just write echo "test123" in it). I read a lot of blogs and so on but I think I'm somehow overlooking the mistake.
what did:
/public_html/app/code/vendor/module/view/frontend/email/voucher_email_template.html
{{template config_path="design/email/header_template"}} <table> <tr class="email-intro"> <td> <p class="greeting">{{var customer_name}},</p> <p> {{trans "Thank you for your order from %store_name." store_name=$store.getFrontendName()}} {{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}} </p> <p> {{trans 'If you have questions about your order, you can email us at <a href="mailxxto:%store_email">%store_email</a>.' store_email=$store_email |raw}} </p> </td> </tr> <tr class="email-summary"> <td> <h1>{{trans 'Your voucher code(s) are the following:</h1> </td> </tr> <tr class="email-items"> <td> {{layout handle="email_voucher_list" items=$vouchers area="frontend"}} </td> </tr> </table> {{template config_path="design/email/footer_template"}}
the phtml which is not included:
/public_html/app/code/vendor/module/view/frontend/templates/email/voucher.phtml
<?php $vouchers = $block->getItems() ?> <table class="email-items"> <thead> <tr> <th class="item-VoucherValue"> <?= /* @escapeNotVerified */ __('VoucherValue'); ?> </th> <th class="item-Code"> <?= /* @escapeNotVerified */ __('Code'); ?> </th> </tr> </thead> <tbody> <?php foreach ($_items as $_item): ?> <tr> <td>$item['VoucherValue']</td> <td>$item['Code']</td> </tr> <?php endforeach; ?> </tbody> </table>
and the XML:
/public_html/app/code/vendor/module/view/frontend/layout/email_voucher_list.xml
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Voucher List" design_abstraction="custom"> <body> <block class="Magento\Framework\View\Element\Template" name="email_voucher_list" template="vendor_module::email/voucher.phtml"/> </body> </page>
I'm thankful for every help.
Regards
Patrick
Solved! Go to Solution.
I found it...
voucher_email_template.html
<h1>{{trans 'Your voucher code(s) are the following:}}</h1>
The closing brackets of this line were missing....
However, what's the difference between:
{{layout handle="email_voucher_list" ....
and
{{block class='Magento\\Framework\\View\\Element\\Template' template='VendorName_ModuleName::email...
?
I found it...
voucher_email_template.html
<h1>{{trans 'Your voucher code(s) are the following:}}</h1>
The closing brackets of this line were missing....
However, what's the difference between:
{{layout handle="email_voucher_list" ....
and
{{block class='Magento\\Framework\\View\\Element\\Template' template='VendorName_ModuleName::email...
?