RSS Feed Question

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2014 01:42 PM
RSS Feed Question - How do you define number of posts displayed on a RSS feed? The FTL file code we are using is below:
FYI: I'm not the developer. This was created by a IT contractor who helped us set-up our Alfresco CMS.
FYI: I'm not the developer. This was created by a IT contractor who helped us set-up our Alfresco CMS.
<#ftl ns_prefixes={"news", "http://www.webbynews.ca/news"}><#assign news = .vars["news:news"]><?xml version="1.0" encoding="ISO-8859-1"?><rss version="2.0"> <channel> <title>Webby News</title> <link>http://www.webbynews.ca</link> <description>Webby News</description> <#assign articleList = null> <#list alf.parseXMLDocuments('Webby News', '/news/xml/') as x> <#assign xmlname = x["@alf:file_name"]> <#assign article_path = "/news/xml/" + xmlname> <#assign listarticle=alf.parseXMLDocument(article_path)> <#assign jspLink = xmlname?string?substring(0, xmlname?string?index_of(".xml"))+ ".jsp"> <#assign articleList = articleList+ [{"title":listarticle["news:title"],"articledate":listarticle["news:active"] ,"url":jspLink ,"body":listarticle["news:content"] }]> </#list> <#list alf.parseXMLDocuments('WEBBY NEWS', '/news/xml/') as x> <#assign xmlname = x["@alf:file_name"]> <#assign article_path = "/news/xml/" + xmlname> <#assign listarticle=alf.parseXMLDocument(article_path)> <#assign jspLink = xmlname?string?substring(0, xmlname?string?index_of(".xml"))+ ".jsp"> <#assign articleList = articleList+ [{"title":listarticle["news:title"],"articledate":listarticle["news:active"] ,"url":jspLink ,"body":listarticle["news:content"] }]> </#list> <#list articleList?sort_by("articledate")?reverse as i> <item> <title>${i.title?string?replace("&","&")}</title> <link>http://www.webbynews.ca/news/articles/${i.url}</link> <description>${i.body?string?replace("<","<")?replace(">",">")}</description> </item> </#list> </channel></rss>
Labels:
- Labels:
-
Archive
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2014 10:53 AM
Hi,
As you may know, this file is formatted with freemarker. And your articleList is a freemarker sequence.
So what you need to do is restrict this sequence to the X first elements.
To do so, please have a look at:
http://stackoverflow.com/questions/18458417/get-sub-list-from-a-list-in-freemarker
If you need it to be modifiable through a parameter, you can just retrieve parameters with the "args" root object
so your webscript would just need a one-line change:
I added parentheses for clarity. AndAssumed a default value of 20 entries when the maxEntries parameter is not specified
I didn't test it so if it causes any syntax error please come back
As you may know, this file is formatted with freemarker. And your articleList is a freemarker sequence.
So what you need to do is restrict this sequence to the X first elements.
To do so, please have a look at:
http://stackoverflow.com/questions/18458417/get-sub-list-from-a-list-in-freemarker
If you need it to be modifiable through a parameter, you can just retrieve parameters with the "args" root object
so your webscript would just need a one-line change:
<#list (((articleList?sort_by("articledate"))?reverse)?chunk((args["maxEntries"]!"20")?number))?first as i>
I added parentheses for clarity. AndAssumed a default value of 20 entries when the maxEntries parameter is not specified
I didn't test it so if it causes any syntax error please come back
