Before you start: These functions do need to be created and edited in the source of the template, and so require a certain level of familiarity with HTML.
As with all templates, we advise that you save a copy of a template to edit - if for any reason the results are not what you expect, you have your original document to fall back on.
This function can be seen as an extension to the merge variables and can be used to control the output based on the content of a merge variable or multiple merge variables.
Using the image below as an example, the function works by checking the field found in A to see if it contains a value, if it finds a value (eg the field is 'not empty') it will add the value found in B to the template.
So in this example, if the contact you are emailing has a first name in the firstname field 'Dear $contacts_firstname ' will be added to the email template, if the contact doest not have a value in the first name field then the email will send without 'Dear $contacts_firstname '.
With this function you can conditionally include any html or merge variables as well as check multiple variables at the same time. The following example demonstrates multiple merge variables being checked and if all the variables contain a value, then the resulting values will display:
IFFIELD[$contacts_firstname&$contacts_lastname][notempty]Dear $contacts_firstname ENDIF
So in this example the function needs to find a value in the first name and last name fields before it can display the value of 'Dear $contacts_firstname'.
Using this logic you can get creative in what values the function can display and what fields the function can check.
It's important to bear in mind that this function work directly on the html code. So when adding it to an email template it is always best to add them in the 'source' rather than on the visual editor. The visual editor is liable to include additional formatting which breaks the syntax and as a result the function might not work correctly.