Skip to navigation

Loading an RSS feed with template tags

Many websites have an RSS feed (or its variant, an Atom feed) linked to them. This contains articles from the site in a standard, machine-readable format. Laposta can read this feed and insert the articles into a template, allowing you to quickly populate a newsletter without copying and pasting.

As soon as you place an RSS block in the newsletter, Laposta loads the feed and displays the items. You can edit the content and the order of the items, and reload the feed.

These tags only apply to an imported HTML template, not to the drag & drop editor. You can read how to import such a template in Importing a custom template into Laposta.

Starting the feed with <lp-rss>

Enclose the feed between <lp-rss> and </lp-rss>. You can include multiple feeds in the same template.

Options

lp-rss-url

Indicates which feed should be loaded.

lp-rss-type

Indicates the feed type: rss or atom. If you omit this attribute, Laposta defaults to rss.

lp-rss-maxitems

The maximum number of items to be loaded. Example: with lp-rss-maxitems="5", at most 5 items are shown. If you omit this attribute, all items are loaded.

You can still adjust this number when populating the newsletter.

lp-rss-range

Indicates a from/to range for the items to be shown, in the format [number]-[number]. With lp-rss-range="2-5", only items 2, 3, 4 and 5 are shown. You can also show a single item, for example lp-rss-range="1-1" for the first item only.

If you omit this attribute, all items are loaded.

lp-rss-striphtml

Sometimes the text in a feed contains HTML. Add this attribute if you do not want that HTML to be displayed in the editor.

lp-rss-maxchars

With lp-rss-maxchars="[x]", you specify that the content of items in the feed must not exceed x characters.

lp-rss-filter

Indicates which items may be shown, based on a field in the feed that can contain multiple values, such as labels or categories. For example, if the feed contains this:

<label>
<item>Pensions</item>
<item>Housing</item>
<item>Labour market</item>
</label>

If you only want to show articles about the labour market or education, the filter looks like this:

lp-rss-filter="label|item|labour market,education"

The format is [field name]|[sub-items name]|valueA,valueB,valueC,...

If the sub-items are located directly in the feed without a parent item, leave the first position empty. For example, if the feed contains this:

<category>Pensions</category>
<category>Housing</category>
<category>Labour market</category>

Then the filter will be:

lp-rss-filter="|category|labour market,education"

Showing text with <lp-rss-content>

The HTML between <lp-rss> and </lp-rss> is repeated for each item in the feed. Within it, you can include the content from the feed.

<lp-rss-content:[veldnaam]>

Field naming varies per feed. Place the name of the field after the colon, for example <lp-rss-content:title> for the title.

For sub-properties and attributes, use a double hyphen: <lp-rss-content:category--term> for <category term="..."/>.

<lp-rss-content:datenl>

A special field that shows the date of the item in Dutch format.

Making content editable

If you want a user to still be able to edit the content when populating the newsletter, use these attributes:

lp-type

With lp-type="singleline|multiline", you specify whether the text is a singleline or a multiline.

lp-edit

Add this to an image to make it editable.

Showing an image with <lp-rss-image>

A feed often contains an image for each item. You can show this using <lp-rss-image>. No special attributes are required. You can use this tag like a regular image.

<lp-rss-image:src>

Use this if you only need the location of the image.

Example

This example loads the feed from the Dutch newspaper de Volkskrant and shows the title with a link, the image and the text for each item.

<lp-rss lp-rss-url="https://www.volkskrant.nl/voorpagina/rss.xml" lp-rss-type="rss" lp-rss-range="1-5">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left">
<a href="<lp-rss-content:link>"><lp-rss-content:title lp-type="singleline"></a>
</td>
</tr>
<tr>
<td align="left">
<lp-rss-image width="560" lp-edit>
</td>
</tr>
<tr>
<td align="left">
<lp-rss-content:description lp-type="multiline">
</td>
</tr>
</table>
</lp-rss>