frosh/templatemail

此包已被弃用且不再维护。未建议替代包。

将邮件模板存储在主题中

安装量: 45,821

依赖者: 0

建议者: 0

安全: 0

星标: 31

关注者: 6

分支: 5

开放问题: 1

类型:shopware-plugin

1.2.0 2022-11-02 08:54 UTC

This package is auto-updated.

Last update: 2024-06-25 17:30:02 UTC


README

将Shopware邮件模板存储在主题中

Join the chat at https://gitter.im/FriendsOfShopware/Lobby Download @ Community Store

此插件允许将邮件存储在主题中而不是数据库中。这给我们带来了以下优势:

  • 更容易部署
  • 使用片段进行翻译
  • 使用包含/扩展/块/继承构建您的邮件模板
  • 使用主题配置

需求

  • Shopware 5.4.x或更高版本
  • PHP 7.0

安装

  • 下载最新版本
  • shopware_folder/custom/plugins/ 中解压zip文件

模板位置

为特定的子商店或语言商店创建邮件(商店中的继承也有效)

示例中的搜索顺序以sOrder为例

HTML模板

  • themes/Frontend/MyTheme/email/sORDER-SHOPID.html.tpl(商店ID)
  • themes/Frontend/MyTheme/email/sORDER.html.tpl(默认)
  • 数据库存储值

文本模板

  • themes/Frontend/MyTheme/email/sORDER-SHOPID.text.tpl(商店ID)
  • themes/Frontend/MyTheme/email/sORDER.text.tpl(默认)
  • 数据库存储值

主题模板

  • themes/Frontend/MyTheme/email/sORDER-SHOPID.subject.tpl(商店ID)
  • themes/Frontend/MyTheme/email/sORDER.subject.tpl(默认)
  • 数据库存储值

加载器

可用的加载器

编写自己的加载器

您还可以实现自定义加载器。创建一个新的类并实现接口 FroshTemplateMail/Components/Loader/MailLoaderInterface,然后使用标签 frosh_template_mail.loader 进行注册。

示例

<?php
namespace MyPlugin;

use FroshTemplateMail\Components\Loader\MailLoaderInterface;
use Shopware\Models\Mail\Mail;

class TwigMailLoader implements MailLoaderInterface {
    
    private $twig;
    
    public function __construct(\Twig_Enviroment $twig)
    {
        $this->twig = $twig;
    }

    public function canHandleExtensions(): array
    {
        return ['twig'];
    }
    
    public function loadMail(Mail $mail, string $templatePath, string $resolvedTemplatePath): string
    {
        return $this->twig->render($resolvedTemplatePath);
    }
}
<service id="my_plugin.twig_loader" class="MyPlugin\TwigMailLoader">
    <argument type="service" id="twig"/>
    <tag name="frosh_template_mail.loader"/>
</service>

贡献

欢迎fork并提交pull请求!

许可证

本项目使用MIT许可证