2018.2

Table Of Contents
var promoTxt = loadhtml('snippets/promo-en.html', '#' +
record.fields['YOGA']);
promoTxt.find('@first@').text(record.fields['FIRSTNAME']);
results.html(promoTxt);
Loading content using a server's API
Content in a template is usually static (apart from being personalized) and part of the main text
flow. It can also be located in a snippet (see "Snippets" on page642).
It is also possible to include content that is served by another server. Many servers provide an
API to fetch publicly available content from their site. That content may even be dynamic: the
most recent blog posts on a Wordpress website, for example, or the current weather forecast
for a certain city.
This topic explains how to retrieve content using a server's API and insert that content in a
template.
Step 1: Getting the appropriate link
To request content from another server, you will need a link.
Some websites give the option to embed their content in your website by providing a link or the
complete HTML. Youtube.com, for example, offers not only a link to share a certain video, but
also the full HTML to embed that video in your website.
If that option is not available, you will have to build the link yourself. Find the server's API and
look through it to get the exact endpoint and parameters that you need.
With many servers it is required to use an API key in the link; this key generally comes for free
after you sign up to their website. The key will be part of the link that is used to make a request
to the server.
Note
Pay attention to the service's Terms of Service. Many servers have limitations on the number of calls
that can be made to them for free. Beyond these limits, their content will not show up in your
template unless you purchase a business plan.
Step 2: Preparing the template
The next step is to set up a template. If you've got the HTML to embed content in your template
you can paste that HTML on the Source tab (and skip Step 3).
Otherwise your template has to contain an element that can be replaced or followed by the
Page 742