This is useful if you want to display some rss content without date/url filters impacting the content. A popular use-case for this is displaying a list of events.
This function expects a valid RSS feed to be returned by the provided URL.
<html>
<body>
[% set events = feed('https://www.feedotter.com/feed') %]
<h2>Display data directly from an rss feed. Bypass the UI.</h2>
<ol>
[% for post in events %]
<li>[[post.post_title]]</li>
[% endfor %]
</ol>
</body>
</html>
Custom JSON/XML Data
Here is a use case where we pull in the first element of a JSON feed. In this case it will be used as an ad.
<html>
<head>
<!-- Fetch and display an ad unit -->
[% set todayDate = "now"|date("Y-m-d") %]
<!-- [[todayDate]] -->
<!-- Query for Newsletter Ad Units -->
[% set ad1 = fetchdata('...your endpoint url here....', '{"Date":"' ~ todayDate ~ '"}')[0] %]
[% set ad2 = fetchdata('...your endpoint url here....')[0] %]
</head>
<body>
<!-- Usage in the Email HTML could look like this: -->
[% if ad1 and ad1|length >0 %]
<div><a href="[[ad1.URL]]" target="_blank">
<img src='[[ad1.Creative]]'></a>
</div>
[% else %]
<!-- Optional Fallback ad if none provided by feed -->
<div><a href="[[custom.topFallbackUrl]]">
<img src='[[custom.topFallbackSrc]]'></a>
</div>
[% endif %]
</body>
</html>