Twig Templates plugin for Dear (dear name or first name) if-exist -> and (spouse first name),

We like including the spouse name in email to our contact out of respect when certain email intended for both so we use Twig Template and create a custom field with spouse first name.

I thought I would share on here on how we set up that it checks for “dear name” which is basically name that contact rather be called by and if dear name not exist then use first name and also check if spouse first exist then include it in the Dear (dear name/first name) and (spouse first name), at the beginning of the email.

This require purchase of Twig Template plugin which can be found over at Twig Templates for Mautic – Mautic Extendee

Here the code

{% if contact.dear_name and contact.spousefirstname %}
<p>Dear {{ contact.dear_name}} and {{ contact.spousefirstname}}:</p>
{% elseif contact.firstname and contact.spousefirstname %}
<p>Dear {{ contact.firstname}} and {{ contact.spousefirstname}}:</p>
{% elseif  contact.dear_name %}
<p>Dear {{ contact.dear_name}}:</p>
{% elseif  contact.firstname %}
<p>Dear {{ contact.firstname}}:</p>
{% endif %}
1 Like