Answers.Body: <p>A little cleaner approach</p>
  
  <pre><code>{if $contact.supplemental_address_1}{contact.supplemental_address_1}{/if}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-23T01:08:00.403Z
Answers.Text: Are you sure about this? It doesn't work for me. Fine if the field is null, but it doesn't print if it is none null. I'm on CiviCRM 4.7.24 and WordPress 4.9 The documentation suggests my solution below.
Answers.UserDisplayName: Mick Kahn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-23T01:38:27.013Z
Answers.Text: Yes. This works in Civi 4.7.20 + WordPress 4.8 and also Civi 4.6.10 + Drupal 7.41 (with smarty turned on of course). I also tested with a few other contact variables include the first_name token listed in the example. They all worked when I used the $variable in the if statement. I hadn't taken an in-depth look at the user guide, I've used the shorter if logic based on samples in the default contribution receipt text. I can't speak to why the user guide recommends assigning an existing contact token first, that's above my pay grade ;)
Answers.UserDisplayName: RayWright
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-23T08:57:26.690Z
Answers.Text: Will try again!
Answers.UserDisplayName: Mick Kahn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-23T13:43:04.430Z
Answers.Text: Tried again very carefully and it still doesn't work. But as I have my own less elegant solution I'm not going to spend more time on it.
Answers.UserDisplayName: Mick Kahn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-03T22:14:09.677Z
Answers.Text: Looks nice but didn't quite work
Answers.UserDisplayName: Yossi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-04T21:24:08.897Z
Answers.Text: As a follow up, apologies I did not test for this distinction before - this works in sending an email (for me) but not print to PDF templates. For print to PDF I had to do the assign method as well.
Answers.UserDisplayName: RayWright
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-20T16:55:36.157Z
Answers.LastActivityDate: 2017-11-20T16:55:36.157Z
Answers.UserDisplayName: RayWright
Answers.Body: <p>Found a whole bunch of examples - including an isset one in Example 7.15</p>
  
  <p><a href="https://www.smarty.net/docsv2/en/language.function.if.tpl" rel="nofollow noreferrer">https://www.smarty.net/docsv2/en/language.function.if.tpl</a> </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-16T14:41:22.730Z
Answers.LastActivityDate: 2017-11-16T14:41:22.730Z
Answers.UserDisplayName: KarinG - Semper IT
Answers.Body: <pre><code>{capture assign=temp}{contact.supplemental_address_1}{/capture} {if $temp ne ""} {$temp}
  {/if} 
  </code></pre>
  
  <p>is what I do. I got the idea from the source referenced above. You also need to ensure that smarty is turned on in civicrm.settings.php</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-18T10:34:51.707Z
Answers.Text: Just found that all this is now very nicely set out in the latest version of the User Guide at https://docs.civicrm.org/user/en/latest/common-workflows/tokens-and-mail-merge/
Answers.UserDisplayName: Mick Kahn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-16T16:20:27.263Z
Answers.LastActivityDate: 2017-11-23T01:03:00.033Z
Answers.LastEditDate: 2017-11-23T01:03:00.033Z
Answers.UserDisplayName: Mick Kahn
Body: <p>How do I do this in a Smarty template:</p>
  
  <p>If {contact.supplemental_address_1} is not empty 
  then <p>{contact.supplemental_address_1}</p>
  
Tags: <smarty>
Title: If statement involving "is not empty" in smarty template?
ThreadText: # If statement involving "is not empty" in smarty template?
  
  (Asked by: username_0 on 2017-11-15)
  
  How do I do this in a Smarty template:
  
  If {contact.supplemental\_address\_1} is not empty
  then
  
  {contact.supplemental\_address\_1}
  
  **Tags:** smarty
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2017-11-16. Score: 4 | Accepted answer
  
  {capture assign=temp}{contact.supplemental_address_1}{/capture} {if $temp ne ""} {$temp}
  {/if} 
  
  is what I do. I got the idea from the source referenced above. You also need to ensure that smarty is turned on in civicrm.settings.php
  
  > **Comments:**
  > **username_2**: Just found that all this is now very nicely set out in the latest version of the User Guide at https://docs.civicrm.org/user/en/latest/common-workflows/tokens-and-mail-merge/  
  
  ---
  
  ### Answer by username_1 on 2017-11-20. Score: 1
  
  A little cleaner approach
  {if $contact.supplemental_address_1}{contact.supplemental_address_1}{/if}
  
  > **Comments:**
  > **username_2**: Are you sure about this? It doesn't work for me. Fine if the field is null, but it doesn't print if it is none null. I'm on CiviCRM 4.7.24 and WordPress 4.9 The documentation suggests my solution below.  
  > **username_1**: Yes. This works in Civi 4.7.20 + WordPress 4.8 and also Civi 4.6.10 + Drupal 7.41 (with smarty turned on of course). I also tested with a few other contact variables include the first_name token listed in the example. They all worked when I used the $variable in the if statement. I hadn't taken an in-depth look at the user guide, I've used the shorter if logic based on samples in the default contribution receipt text. I can't speak to why the user guide recommends assigning an existing contact token first, that's above my pay grade ;)  
  > **username_2**: Will try again!  
  > **username_2**: Tried again very carefully and it still doesn't work. But as I have my own less elegant solution I'm not going to spend more time on it.  
  > **username_0**: Looks nice but didn't quite work  
  > **username_1**: As a follow up, apologies I did not test for this distinction before - this works in sending an email (for me) but not print to PDF templates. For print to PDF I had to do the assign method as well.  
  
  ---
  
  ### Answer by username_3 on 2017-11-16. Score: 1
  
  Found a whole bunch of examples - including an isset one in Example 7.15
  
  <https://www.smarty.net/docsv2/en/language.function.if.tpl>
  
  
  ---
  
  