To generate the emails of the e-Alerts, two types of templates are used. One template represents the HTML version, the other a plain text version of the email being generated.
Both templates consist of two parts. The first part is used as the main template of the email. The second part is used as a template for the snippets, which are included in the email template.
Freemarker templating engine
The templates make use of the FreeMarker templating engine. This means that default FreeMarker functionality is supported by the templates. There are also a few default properties available, which can be used in your template.
Setting up the main template
The main template should contain the main layout of the email and a reference to the snippets that are created per email. This is one of the default properties that are available in the templating engine. It can be referenced in the following manner:
{snippets}
There are some default properties available in the main template.
Date property
The current date (when the document is processed) is available in the main template:
${date}
This is an example of how to use formatting on this date:
[#assign dateFormat="d-M-yyyy"]
${date?string(dateFormat)}
Subscriber properties
The template contains a properties of the subscriber of the email. These properties can be accessed by:
${subscriber.propertyValue}
Available properties:
| Property | Description | Since version |
|---|---|---|
| ${subscriber.firstName} | The first name of the subscriber | 2.02.00 |
| ${subscriber.namePrefix} | The middle name of the subscriber (for Dutch users: "tussenvoegsel") | 2.02.00 |
| ${subscriber.fullName} | The full name of the subscriber | 2.02.00 |
| ${subscriber.email} | The email address of the subscriber | 2.02.00 |
| ${subscriber.gender} | The gender of the subscriber | 2.02.00 |
| ${subscriber.userInterests} | An alphabetically ordered HashMap with the subscribed interest categories and the interests | 2.02.01 |
NOTE: whether these properties contain data, depends on whether there are values provided for these properties
Setting up the snippets
For each changed document within the configured parts on the website a snippet is generated. This snippet may contain a title, introduction, author information or any other part of the document and a link to that document on the website.
In this snippet template there are some default properties available. These are divided by properties by default snippet, which will be available for every snippet, and document specific properties.
Snippet properties
The snippet properties can be accessed in the following manner:
${snippet.propertyName}
Available properties:
| Property | Description | Since version |
|---|---|---|
| ${snippet.id} | id of the snippet (this should be used to reference the document) | 2.02.00 |
| ${snippet.siteUrl} | URL that is used to resolve the snippets to a view of the document | 2.02.00 |
| ${snippet.interests} | comma separated list of interest names for this snippet Only for the category that is marked to display its properties in the e-Alert. |
2.02.01 |
Document specific properties
The properties of the document (original document of the snippet) can be accessed in the same manner as the snippet properties:
${document.propertyName}
The available properties depend on the properties that are available for that document. Use the names of the WebDAV properties that are set on the documents.
Links generating
For the generating of links to the document of the snippets, the siteUrl and id of the snippets should be used. This should link to a page on a website that resolves the snippet id to a view of the underlying document.
A simple example
This is a simple example of a plain text e-Alert.
The main template
[#ftl]
[#assign dateFormat="d-M-yyyy"]
The e-Alert Email of ${date?string(dateFormat)}
Dear ${subscriber.fullName},
This is an automatically generated email by Hippo e-Alert.
Your subscription:
[#list subscriber.userInterests.keySet() as interestCategory]
{interestCategory}
[#list subscriber.userInterests[category] as interests]
- ${interests}
[/#list]
[/#list]
It contains the following snippets:
${snippets}
Hippo
The snippet template
[#ftl] [#if document.title?has_content]${document.title} - ${snippet.siteUrl}${snippet.id}[/#if] [#if document.introduction?has_content]${document.introduction}[#else]${document.caption}[/#if]
|
Each Freemarker template must start with [#ftl] |
Sample e-Alert
The e-Alert Email of 27-8-2008 Dear John Doe, This is an automatically generated email by Hippo e-Alert. Your subscription: Document Type - Events - News Subjects - Content management - Internet - Web development It contains the following snippets: Hippo sends e-Alerts - http://onehippo.com/e-AlertSnippet?id=12345 Hippo starts sending e-Alerts. The e-Alerts generates e-mail when pages have been updated on your website. Visitors can set the frequency of the mails and the subject(s) of their interest. The interests and the markup of the e-Alerts are managed in Hippo CMS. Hippo sponsor Apachecon USA - http://onehippo.com/e-AlertSnippet?id=12346 Hippo will be one of the sponsors for this year's Apachecon US held in New Orleans. Hippo