How to Edit Employee and Admin E-mail Templates

Introduction

This article is guideline to editing all types of templates. These can be for emails, contracts and invoices.

You can find them in Settings/Email Templates. Each type of template has its own section.

Hybrid email templates.png

Whenever you open a template, there are two options to edit it - Editor and Code.

template edit hybrid.png

Contents

Using the editor to edit templates

In the editor, you can see a preview that's easier to read and handle. It works similarly to a regular text editor. 

Here are the functions of the editor:

  • Insert property - allows you to add some of the properties, that are available for the selected type of template. For a full list of all available properties, please check the following article.
  • Format - select the type of text you want to use:
    • Paragraph
    • Quotation
    • Heading 1 to Heading 6
  • Font Type
  • Font Size
  • Font Colour
  • Background Colour
  • Bold
  • Italic
  • Underline
  • Strikethrough
  • Alignments
    • Align left
    • Align center
    • Align right
    • Justify
  • Insert unordered list
  • Insert ordered list
  • Indent
  • Insert hyperlink
  • Subscript
  • Superscript
  • More tools
    • Clean formatting - removes all formatting for the selected text.
    • Table Wizard - allows you to create a table with the details that you've specified in the menu:

      table wiz.png

How to edit the code of a template

If you click Code, you'll see what lies behind this preview - HTML code. Everything you do in the editor is translated into HTML. If you are familiar with HTML, you can do a lot with manual scripting. But for now, we are going to cover how to add properties directly in the code. Let's take a look at a default "Welcome" email template in code. 

code.png

Notice how in the Editor view, the properties are shown in square brackets [property] and yellow color. In the code, they look like this: {{ property }}.

There are many properties you can use. Although lot of them can be added through the editor's "Insert Property" in the editor, but not all are there.

Those lists are almost complete, with the major exception of this are custom properties.

The only way to insert a custom property is through code and we'll cover this below.

How to add custom properties to templates

Custom properties are applied to different sections of the site. For example members, companies, locations etc. Click here to learn more.

In order to reference a custom property in the template, you need to use its unique identifier.

If you already know where to place it and you can get around the code by yourself, then you can do it directly. Another option is to go back to the editor and follow these steps:

  1. Insert a placeholder string of text, e.g PROPERTY HERE
  2. Switch back to code
  3. Find where the property you just inserted is and replace it

We advise that you clone your template using the Clone button and test it before editing the default template.

Note: Email templates cannot be cloned, so take care when editing those types of templates.

How to add if (conditional) statements to templates

If you'd like to make the content of your template vary based on a specific property you can write an if statement.
This can be done by using the property name as follows:

{% if propertyName === value %}
This text will appear of the propertyName equals the value you've specified.
{% else %}
This text will appear if the propertyName equals something else different from the selected value.
{% endif %}

The main thing to consider when writing your "if" is the type of the property for which the if is being written:

  • String - you need to use quotes, e.g. propertyName === "value".
  • Number - just enter the numerical value. You can also use <,>,>=,<=, operators as wel as "===".
  • Boolean - you need to use quotes and check if the property is equal to "yes", e.g. booleanPropertyName === "yes".

It's also important to note that sometimes numerical values are formatted strings. This means you'll need to remove the formatting in order to write if statements for them.
This can be done by using parseMoney.

Example:

{% if parseMoney(contract.total) > 2000 %}
The contract costs more than 2000/year.
{% endif %}

Note: In order to find out whether a property needs to be parsed, it's best to first test the property itself by genering an example template. If it's a formatted number, parse it - if not you can write the if statement directly.

How to revert changes

You can abandon the changes you've made and revert to the default template by using the Revert button. rev btn.png

 

Was this article helpful?
0 out of 0 found this helpful
Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.