tom*_*rne 1 email smarty smarty3 shopware
我的电子邮件模板有点问题。Shopware 出于某种原因使用 Smarty 作为其电子邮件的模板语言。我现在的问题是我有这个电子邮件模板
Tracking:
{if $sDispatch.name == "DHL national" }
https://sampleurl.com={$sOrder.trackingcode}
{else if $sDispatch.name == "DPD"}
https://sampleurl.com={$sOrder.trackingcode}
{else if $Dispatch.name == "Deutsche Post"}
http://sampleurl.com
{else}
Your order can not be tracked.
{/if}
Run Code Online (Sandbox Code Playgroud)
包裹有很多派送选项(小包裹,有保险......)。现在我想检查 $sDispatch.name 中的字符串是否包含“DHL”、“DPD”或“Deutsche Post”,以确定应将哪个跟踪链接发送给客户。
我找不到合理的解决方案来检查字符串是否包含这些给定子字符串的片段。有没有人有一个巧妙的小解决方案可以解决问题?任何东西都值得赞赏!:-)
小智 11
您可以使用修饰符 |strstr 来搜索字符串中的某个字符串。
https://www.php.net/manual/de/function.strstr.php
例子:
{if $sDispatch.name|strstr:"DHL"}This is a dispatch that contains the string DHL{/if}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3131 次 |
| 最近记录: |