cancel
Showing results for 
Search instead for 
Did you mean: 

Open External URL in Freemarker

simon
Champ in-the-making
Champ in-the-making
Hi Alf,

I would like to parse an external XML file (an RSS feed) in a Freemarker template. Is this possible? It's simple when the RSS feed would be stored in the repository, I would only need to call the reference to the document like this:
companyhome.nodeByReference["workspace://SpacesStore/e661dccb-ecc0-11da-9974-63f65406985a"]
But I would like to read an external RSS feed (e.g. http://www.example.com/rss/example.xml), is this possible?

Thanks!
3 REPLIES 3

jbarmash
Champ in-the-making
Champ in-the-making
I don't believe Freemarker allows this out of the box. However, Alfresco allows you to add your own apis to Freemarker.  You could write a Java class that pulls in the URL by exposign a Custom Root object to Freemarker.   It's quite easy, I've done it several times for projects.

http://wiki.alfresco.com/wiki/Template_Guide#Custom_Root_Objects

simon
Champ in-the-making
Champ in-the-making
Thanks jbarmash, I was hoping for an easy solution but I'm afraid there isn't any. Will have to learn some Spring magic…

jbarmash
Champ in-the-making
Champ in-the-making
It's actually not too hard to expose Java in Freemarker.  See this link for a sample I just uploaded.  The sample also allows you to pull in output of a web script into Freemarker, so that piece could be useful as well.  If you write a Web Script that does what you need to do, you can include that easily in FreeMarker. 

http://community.alfresco.com/alfresco/n/showDocDetails/workspace/SpacesStore/e7978614-646e-11dd-992...