Use two Articles and a Foreach loop to insert a specific number of entries from an RSS feed in a Template.
To include a specific number of RSS Feed entries
First, create an Article to call the RSS Feed Reference Tags:
- Go to CONTENT > VIEW ARTICLES to view the list of articles.
- Click Add Article to open the Add Article page.
- Enter the Article Name and Description.
- For the Body, add the RSS Feed Entry Tags you wish to display. The [NAME] must match the [NAME] you will define in your Template. See the examples below.
- Click CREATE to save the Article.
Next, create an article to define the limit and check if it has been reached. In the example below, the limit will display the three most recent entries.
- Go to CONTENT > VIEW ARTICLES to view the list of articles.
- Click Add Article to open the Add Article page.
- Enter the Article Name and Description.
- For the Body, add the RSS Feed Entry Tags you wish to display.
%%if [NAME].index < [NUMBER] then includearticle "[ARTICLE1_NAME]"%%
where [NAME] is the identifier within your content, [NUMBER] is the number of entries you wish to display, and [ARTICLE1_NAME]is the name of the article in which the RSS Feed References are defined. The [NAME] must match the [NAME] you will define in your Template. See the examples below.
- Click CREATE to save the Article.
Finally, create a Template and Define the RSS Feed and call the Article:
- Click Go to CONTENT > VIEW TEMPLATES to view the list of templates.
- Click Create new template to open the Add Template page.
- Enter a Name and Subject.
- Click the format tab in which you wish to include the feed: Plain Text, HTML, Mobile.
- In the Template area, add the RSS Feed Definition Tag:
%%rssfeed url=[URL] name=[NAME]%%
where [URL] is the URL to access the RSS feed, [NAME] is the identifier within your content.
- Add a foreach tag to call the Article in which the feed is referenced:
%%foreach "[NAME]" article "[ARTICLE2_NAME]" type=rss%%
where [NAME] is the identifier within your content and [ARTICLE2_NAME]is the article in which the loop counter is defined.
- Click CREATE to save the Template.
Plain Text Example
Article 1 Name: RSSDisplay_plain
Article 1 Description: RSS Display Plain
Article 1 Body:
%%rssfeed url=http:// mydomain.com/rss/feed name=myfeed%%
%%rssobject myfeed.title.striphtml%%
%%rssobject myfeed.link%%
%%rssobject myfeed.pubdate%%
%%rssobject myfeed.description.striphtml%%
Article 2 Name: RSSFeed_plain
Article 2 Description: RSS Feed Plain
Article 2 Body:
%%if myfeed_PT.index < 3 then includearticle "RSSDisplay_plain"%%
Template RSS Tag Call:
%%rssfeed url=http:// mydomain.com/rss/feed name=myfeed_PT%%
%%foreach "myfeed_PT" article "RSSFeed_plain" type=rss%%
HTML Example
Article 1 Name: RSSDisplay_HTML
Article 1 Description: RSS Display HTML
Article 1 Body:
%%rssfeed url=http:// mydomain.com/rss/feed name=myfeed%%
<p><a href="%%$rssobject myfeed.link%%"><b>%%$rssobject myfeed.title%%</b></a><br />
%%$rssobject myfeed.pubdate%%<br />
%%$rssobject myfeed.description%%<br />
%%$rssobject myfeed.content%%</p>
<img src="%%$rssobject myfeed.mediaimage%%" width="250px" /></p>*
Article 2 Name: RSSFeed_HTML
Article 2 Description: RSS Feed HTML
Article 2 Body:
%%if myfeed.index < 3 then includearticle "RSSDisplay_HTML"%%
Template RSS Tag Call:
%%rssfeed url=http:// mydomain.com/rss/feed name=myfeed%%
%%foreach "myfeed" article "RSSFeed_html" type=rss%%
*Image support added in v11.9.0