Answers.Body: <p>Try</p>
  <pre><code>{capture assign=contribution_type}{contribution.financial_type_id}{/capture} 
  {if $contribution_type eq 1}This is for Membership. {else}This is for Donation. {/if}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-29T14:11:09.733Z
Answers.Text: Thanks so much.  Just syntax.  I thought I had tried all the combinations...
Answers.UserDisplayName: shibetpc
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-29T12:07:22.193Z
Answers.LastActivityDate: 2023-01-29T12:07:22.193Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I just can't seem to get any conditional statement to work using Smarty.  Essentially, the logic should say, 'if the contribution is Membership Dues, say this.  If it's a Donation, say this'.</p>
  <p>I'm using other Smarty content in the template and it works fine, but as soon as I add the 'if' statement I get a fatal error.</p>
  <p>Here's what I currently have:</p>
  <p>{capture assign=contribution_type}{contribution.financial_type_id}{/capture}
  {if &quot;$contribution_type&quot; == &quot;1&quot;}This is for Membership.
  {else}This is for Donation.
  {/if}</p>
  <p>Things I've tried:</p>
  <ul>
  <li>Set CKeditor - Entities =True</li>
  <li>Every variations of wrapping field and value in &quot;&quot; or '' or nothing.</li>
  <li>adding {} around the field e.g. {$contribution_type}, with and without single and double quotes.</li>
  <li>with and without the $</li>
  </ul>
  <p>Am I missing something obvious or misunderstanding altogether?</p>
  <p>Wordpress: 6.1.1
  CiviCRM: 5.55.2</p>
  <p>Much thanks in advance for any insight.</p>
  
Tags: <message-templates><smarty>
Title: Smarty conditional statement in Message Template (contribution.financial_type_id)
ThreadText: # Smarty conditional statement in Message Template (contribution.financial_type_id)
  
  (Asked by: username_0 on 2023-01-29)
  
  I just can't seem to get any conditional statement to work using Smarty. Essentially, the logic should say, 'if the contribution is Membership Dues, say this. If it's a Donation, say this'.
  
  I'm using other Smarty content in the template and it works fine, but as soon as I add the 'if' statement I get a fatal error.
  
  Here's what I currently have:
  
  {capture assign=contribution\_type}{contribution.financial\_type\_id}{/capture}
  {if "$contribution\_type" == "1"}This is for Membership.
  {else}This is for Donation.
  {/if}
  
  Things I've tried:
  
  * Set CKeditor - Entities =True
  * Every variations of wrapping field and value in "" or '' or nothing.
  * adding {} around the field e.g. {$contribution\_type}, with and without single and double quotes.
  * with and without the $
  
  Am I missing something obvious or misunderstanding altogether?
  
  Wordpress: 6.1.1
  CiviCRM: 5.55.2
  
  Much thanks in advance for any insight.
  
  **Tags:** message-templates, smarty
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-01-29. Score: 2 | Accepted answer
  
  Try
  {capture assign=contribution_type}{contribution.financial_type_id}{/capture} 
  {if $contribution_type eq 1}This is for Membership. {else}This is for Donation. {/if}
  
  > **Comments:**
  > **username_0**: Thanks so much.  Just syntax.  I thought I had tried all the combinations...  
  
  ---
  
  