Answers.Body: <p>I feel the statement should be something like this</p>
  
  <pre><code>{capture assign=newsletter}Yes{/capture}
  {if $newsletter eq 'Yes'}
    You agreed to receive our emails.
  {/if}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-08T17:33:31.503Z
Answers.Text: The problem is that none of the code is being processed. So I took some code directly from here: https://docs.civicrm.org/user/en/latest/common-workflows/tokens-and-mail-merge/
  
  So for example, this:
  {capture assign=first_name}{contact.first_name}{/capture}
  Dear {$first_name|default:Friend},
  {if $first_name}
    Hello, {$first_name}, how are you?
  {/if}
  
  doesn't get processed. Instead the code itself shows up in the email.
  
  Is it because of Mosaico and Flexmailer that you have to install with it? Is it because the smarty line isn't being applied somehow in civicrm.settings.php?
Answers.UserDisplayName: Rachelle Niemela
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-08T17:45:40.573Z
Answers.Text: Can you check the source code of ckeditor? I feel it is somewhat related to https://civicrm.stackexchange.com/a/22618/155
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-09T04:35:48.110Z
Answers.Text: Tried that and no change. I was using the TinyMCE editor extension and disabled that just in case.
Answers.UserDisplayName: Rachelle Niemela
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-09T04:44:21.513Z
Answers.Text: More testing: it's now working in the New Mailing (Traditional) but not in Mosaico. Will dig more.
Answers.UserDisplayName: Rachelle Niemela
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-09T05:25:49.017Z
Answers.Text: Reverted the setting for ckeditor and reactivated TinyMCE and New Mailing (Traditional) is still working. So the problem is definitely with Mosaico.
Answers.UserDisplayName: Rachelle Niemela
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-08T04:18:28.810Z
Answers.LastActivityDate: 2018-02-08T04:18:28.810Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I'm not sure where to look - I've tried everything that I can think of to get smarty to work in an email template, but it's just not happening.</p>
  
  <p>I'm using CiviCRM 4.7.27 with WordPress 4.9.3.</p>
  
  <p>I've changed the smarty setting in /public_html/wp-content/uploads/civicrm/civicrm.settings.php:</p>
  
  <p>if (!defined('CIVICRM_MAIL_SMARTY')) {
    define( 'CIVICRM_MAIL_SMARTY', 1 );
  }</p>
  
  <p>But I can't get a smarty statement to work in a mailing.</p>
  
  <p>If I use a Mosaico template, I get the source code in the email eg
  {capture assign=newsletter}Yes{/capture}
  {if $newsletter == Yes}
  You agreed to receive our emails.
  {/if}</p>
  
  <p>If I use a new mailing (traditional) using the Sample CiviMail Newsletter template and try to test the mailing, I get an error message:
  " Sorry an error occurred and your information was not saved"</p>
  
  <p>Tokens work fine.</p>
  
  <p>Any idea re what the problem is?</p>
  
  <p>UPDATE:</p>
  
  <p>Have gotten Traditional mail to output the Smarty code properly. It was all due to some syntax issues. It's hard to test under an administrator account which may not have the same contents as a regular account. The remaining problem is that Mosaico templates don't work. Here's a sample of what comes through:</p>
  
  <p>{capture assign=contactId}18{/capture}
  {crmAPI var='result' entity='Membership' action='getcount' sequential=0 contact_id=$contactId membership_type_id="Family" active_only=1}
  {if $result gt 0}
  Dear Test and family, {else} Dear Test, {/if}</p>
  
  <p>Thank you for purchasing a 2018 membership!</p>
  
  <p>{capture assign=newsletter}Yes{/capture}
  {if $newsletter}Because you've indicated you'd like to receive our e-news, you’ll get our newsletter about once a month with info on cycling events and issues, volunteer opportunities, and cycling events and meetings.{/if}
  {capture assign=interests}5{/capture}</p>
  
  <p>{if $interests}You've also indicated that you're interested in participating in some of our activities. We'll send you information when there's one of your chosen activities planned.{/if}</p>
  
  <p>{capture assign=volunteer}5{/capture}
  {if $volunteer}Since you also indicated you're interested in voluneering for some of our activities, one of our activity team leaders will contact you when there's an opportunity to volunteer to help out.{/if}</p>
  
  <p>If anyone has any ideas, that would be great.</p>
  
Tags: <civimail><email><smarty>
Title: Problems getting smarty to work
ThreadText: # Problems getting smarty to work
  
  (Asked by: username_0 on 2018-02-08)
  
  I'm not sure where to look - I've tried everything that I can think of to get smarty to work in an email template, but it's just not happening.
  
  I'm using CiviCRM 4.7.27 with WordPress 4.9.3.
  
  I've changed the smarty setting in /public\_html/wp-content/uploads/civicrm/civicrm.settings.php:
  
  if (!defined('CIVICRM\_MAIL\_SMARTY')) {
  define( 'CIVICRM\_MAIL\_SMARTY', 1 );
  }
  
  But I can't get a smarty statement to work in a mailing.
  
  If I use a Mosaico template, I get the source code in the email eg
  {capture assign=newsletter}Yes{/capture}
  {if $newsletter == Yes}
  You agreed to receive our emails.
  {/if}
  
  If I use a new mailing (traditional) using the Sample CiviMail Newsletter template and try to test the mailing, I get an error message:
  " Sorry an error occurred and your information was not saved"
  
  Tokens work fine.
  
  Any idea re what the problem is?
  
  UPDATE:
  
  Have gotten Traditional mail to output the Smarty code properly. It was all due to some syntax issues. It's hard to test under an administrator account which may not have the same contents as a regular account. The remaining problem is that Mosaico templates don't work. Here's a sample of what comes through:
  
  {capture assign=contactId}18{/capture}
  {crmAPI var='result' entity='Membership' action='getcount' sequential=0 contact\_id=$contactId membership\_type\_id="Family" active\_only=1}
  {if $result gt 0}
  Dear Test and family, {else} Dear Test, {/if}
  
  Thank you for purchasing a 2018 membership!
  
  {capture assign=newsletter}Yes{/capture}
  {if $newsletter}Because you've indicated you'd like to receive our e-news, you’ll get our newsletter about once a month with info on cycling events and issues, volunteer opportunities, and cycling events and meetings.{/if}
  {capture assign=interests}5{/capture}
  
  {if $interests}You've also indicated that you're interested in participating in some of our activities. We'll send you information when there's one of your chosen activities planned.{/if}
  
  {capture assign=volunteer}5{/capture}
  {if $volunteer}Since you also indicated you're interested in voluneering for some of our activities, one of our activity team leaders will contact you when there's an opportunity to volunteer to help out.{/if}
  
  If anyone has any ideas, that would be great.
  
  **Tags:** civimail, email, smarty
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-02-08. Score: 1
  
  I feel the statement should be something like this
  {capture assign=newsletter}Yes{/capture}
  {if $newsletter eq 'Yes'}
    You agreed to receive our emails.
  {/if}
  
  > **Comments:**
  > **username_0**: The problem is that none of the code is being processed. So I took some code directly from here: https://docs.civicrm.org/user/en/latest/common-workflows/tokens-and-mail-merge/  So for example, this: {capture assign=first_name}{contact.first_name}{/capture} Dear {$first_name|default:Friend}, {if $first_name}   Hello, {$first_name}, how are you? {/if}  doesn't get processed. Instead the code itself shows up in the email.  Is it because of Mosaico and Flexmailer that you have to install with it? Is it because the smarty line isn't being applied somehow in civicrm.settings.php?  
  > **username_1**: Can you check the source code of ckeditor? I feel it is somewhat related to https://civicrm.stackexchange.com/a/22618/155  
  > **username_0**: Tried that and no change. I was using the TinyMCE editor extension and disabled that just in case.  
  > **username_0**: More testing: it's now working in the New Mailing (Traditional) but not in Mosaico. Will dig more.  
  > **username_0**: Reverted the setting for ckeditor and reactivated TinyMCE and New Mailing (Traditional) is still working. So the problem is definitely with Mosaico.  
  
  ---
  
  