0

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.

1 Answer 1

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}
5
  • The problem is that none of the code is being processed. So I took some code directly from here: docs.civicrm.org/user/en/latest/common-workflows/… 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? Commented Feb 8, 2018 at 17:33
  • Can you check the source code of ckeditor? I feel it is somewhat related to civicrm.stackexchange.com/a/22618/155 Commented Feb 8, 2018 at 17:45
  • Tried that and no change. I was using the TinyMCE editor extension and disabled that just in case. Commented Feb 9, 2018 at 4:35
  • More testing: it's now working in the New Mailing (Traditional) but not in Mosaico. Will dig more. Commented Feb 9, 2018 at 4:44
  • Reverted the setting for ckeditor and reactivated TinyMCE and New Mailing (Traditional) is still working. So the problem is definitely with Mosaico. Commented Feb 9, 2018 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.