It is possible to retrieve an RSS/JSON feed and display the result in HTML when rendering your webpage or email. This can be used, for example, to promote the best-selling items from your website or personalize an email with data from the user most favorite store.

It can also be used to retrieve the latest product catalog, allowing you to save a lot of time when creating your newsletters.



Installation

In the Deployteq Store, you can find the module called "Data feeds";

With two steps, you can have the app installed. The first step is the actual installation, and the second step is the financial administration, as you are accustomed to from us.

In your emails and pages, you can now use the Smarty functions getRss and getJSON to retrieve the feed. With Smarty, you can translate this into the desired HTML format.


Impact on the sending speed

This Smarty solution can impact the sending speed of your email if a personalized feed is used within a batch selection or when the feed is too large in terms of data. An alternative is to preload the data into the data model beforehand and use it to display the information in the email. 

Example getRSS

getRss Smarty function
{{getRss assign='<variabel name>' link='<url>'}}
<!--{getRss assign='rssdata' link='https://www.emerce.nl/nieuws/feed'}-->

<!--{foreach from=$rssdata.channel[0].item item=data}-->
 Titel: {{$data.title}}<br/>
 Link: {{$data.link}}<br/>
<!--{/foreach}-->

To determine how the RSS feed is structured, you can use the Smarty method var_dump or print_r;

getRss Structure

<!--{getRss assign='rssdata' link='https://www.emerce.nl/nieuws/feed'}-->

<pre>

{{$rssdata|var_dump}}

</pre>

Enclosure tags

The getRSS smarty method doesn't support enclosed arguments within an XML element such as the example argument "name" below:

<element name="Test">

Example getJSON

getJSON Smarty function
{{getJSON assign='<variabel name>' url='<url>'}}
<!--{getJSON assign='jsondata' url='https://data.nasa.gov/resource/y77d-th95.json'}-->
        
<!--{foreach from=$jsondata key=key item=item}-->
   Name: {{$item.name}}<br/>
   Nametype: {{$item.nametype}}<br/>
<!--{/foreach}-->

To determine how the JSON feed is structured, you can use the Smarty method var_dump or print_r:

getJSON Structure

<!--{getJSON assign='jsondata' url='https://data.nasa.gov/resource/y77d-th95.json'}-->

<pre>

{{$jsondata|var_dump}}

</pre>