Create Dynamic Content templates with an external database (XML content)

With the Flexmail HTML Editor it is possible to create a template message and automatically feed data into it from an external database via an XML file. This article will give you detailed instructions and examples how to do that and what the result could be. 


How it works - in principle

  1. First, you create a Dynamic Content Template from the HTML Editor. The message template will serve as the layout structure. In the template, you can configure variables that you can customise for every message you send out. 
  2. Examples for variables could be:
    	[$title]
    	[$article.header1]
    	[$article.content1]
    	[$article.header2]
    	[$article.content2]
    	etc.
    	
  3. Next, you create an XML file where the content you want to insert in the template will be put between the respective tags of the variables you created:
  4. 	<title></title>
    	<article.header1></article.header1>
    	<article.content1></article.content1>
    	<article.header2></article.header2>
    	<article.content2></article.content2>
    	etc.
    	
  5. Then, Flexmail will automatically generate a newsletter based on your template and your XML file. You can upload the XML file or you can paste the content of this file in Flexmail.

How to do it - in practice

  1. Go to Campaigns > Messages. Click on Create new message.
  2. Select the HTML Editor for a tool to create it. You probably want to choose No Template and do your own code from scratch. Type in a name and click on Save.

  3. In your WYSIWYG editor, click on the HTML button.
  4. Input your HTML code with the corresponding placeholders. Click on Update to apply the code.
  5. Save and close your message.
  6. Save your message as a template. Just find it in your list of messages, then click in the gear icon to your right. Find and click on the option Save message as a template.
  7. Go back to the first step to create a message.

  8. Here, select the HTML editor for a tool, uncheck no template, check use XML input. A new text field will appear. Add the XML content in it. Click to Select your template. Click on Save to start your message.


Examples

Case 1

Template

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
   <title>Newsletter</title>
</head>
<body>
   <p><font face="helvetica">[$content]</font></p>
</body>
</html>

XML data file

<xml version="1.0" encoding="UTF-8">
<data>
  <content>Hello World!</content>
</data>
</xml>

Email message

Case 2

Template

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <title>Newsletter</title>
</head>
<body>
  <h1>[$title]</h1>
  <p>[$text]</p>
</body>
</html>

XML data file

<xml version="1.0" encoding="UTF-8">
<data>
  <title>Newsletter October 2020</title>
  <text> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</text>
</data>

Email message

Case 3

Template

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <title>Newsletter</title>
</head>
<body>
  <h1>BBC World News</h1>
  <table border="0">
    <tbody>
[foreach from=$articles item=article name=articleIterator]
      <tr>
        <td><h2>[$article.title]</h2></td>
      </tr>
      <tr>
        <td><img src="[$article.image]" width="300" align="left" /><b>[$article.intro]</b> <br /> <br /> [$article.text|nl2br]</td>
      </tr>
      <tr>
        <td><a href="[$article.url]" target="_blank">Read more</a></td>
      </tr>
  [if $smarty.foreach.articleIterator.last==false]
      <tr>
        <td><hr /></td>
      </tr>
  [/if] 
[/foreach]</tbody>
  </table>
</body>
</html>

XML data file

<xml version="1.0" encoding="UTF-8">
<data>
  <articles>
    <article>
      <title>Small fashion brands in Asia hit by economic decline</title>
      <intro>Fashion entrepreneurs are feeling the heat as supplies are getting disrupted</intro>
      <text>A recent report by consultants McKinsey &amp; Company forecast that revenues for the global fashion industry will drop by up to 30% this year, with that figure coming in at 40% for the luxury end of the market.</text>
      <url> http://yourfashioncompany.com/news/world-asia-pacific-1588424000</url>
      <image> https://app.flexmail.eu/dyn/wizard/1401/assets/1803460/shoes.jpg</image>
    </article>
    <article>
      <title>Will the fashion industry have to rethink its values?</title>
      <intro> Fashion entrepreneurs are feeling the heat as supplies are getting disrupted.</intro>
      <text> Normally, at this time of year, many of us would be curating our perfect summer wardrobe as we prepare for sunny weather and foreign holidays.</text> 
      <url>http://yourfashioncompany.com/news/fashion-industry-rething-values-49816534/</url>
      <image>http://app.flexmail.eu/dyn/wizard/1401/assets/1803460/lady.jpg</image>
    </article>
  </articles> 
</data> 
</xml>

Email message


There is more that you can do in Flexmail
Looking for some background information?
Get inspired!
Did this answer your question? Thanks for your feedback There was a problem submitting your feedback. Please try again later.

Didn't find what you were looking for? Contact Us Contact Us