Announcement

Collapse
No announcement yet.

How to use #if on email template

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use #if on email template

    I using Hook for send email and it work now.

    But I can't use #if condition on EmailTemplate

    I tried

    {{#ifEqual showPhone 'Yes'}}
    {SendEmailToClient.companyName}
    {{else}}
    {SendEmailToClient.showPhone}
    {{/ifEqual}}

    showPhone is enum-field

    and I receive this on email

    {{#ifEqual showPhone 'Yes'}} Ekko Lab AI Co.,Ltd. {{else}} Yes {{/ifEqual}}


  • #2
    Did you insert the #if condition in the code view? And you have to comment out the code (<!-- xxx -->).
    Another mistake could be "yes". I guess it is a bool field? Then you have to use true/false (yes/no).
    And it should be ifEquals, with an "s" at the end.
    And I also think, you don`t even need ifEquals in this case, only if should do it.

    If you want more insight, how this works, perhaps this could help: https://handlebarsjs.com/guide/
    Last edited by shalmaxb; 09-10-2021, 07:18 AM.

    Comment


    • #3
      You need to pass 'parent' => $entity with email template params to make htmlizer working. I recommend to debug code of the method you invoke to find out the problem.

      p.s. this has nothing to to extensions. It's out-of-the-box (experimental) feature.

      Comment

      Working...
      X