Customizing RSS Feed | Community
Skip to main content
October 16, 2015
Solved

Customizing RSS Feed

  • October 16, 2015
  • 13 replies
  • 6079 views

I have children pages that I would like to display in rss xml using page.feed.rss.xml.  I placed the /feed.jsp and /feedentry.jsp from /libs/foundation/component/page into my /apps/[project]/component/page and to change the defined atom:link and atom:publish.  However, the rss feed is not picking up the change.  It does not appear to be pointing to the feed jsp under /libs/foundation/components/page which the sling resource resolver for /page.feed shows /libs/sling/servlet/default/feed.jsp.  I have even tried creating feed.rss.xml.jsp in my project page component with no success.

Also the sling servlet resolver referenced com.day.cq.commons.servlets.FeedRendererServlet and I wondering if the returned atom xml goes through this render to get the resulting xml page.feed.rss.xml.  If that is the case, I would I go about making changes to the atom:publish and atom:link.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Ojjis

I was doing a similar thing.
It is possible to override  the "foundation/components/primary/cq/Page/feed.jsp" to control you own way of what should be included in the feed from the page that you "start from", in you case "/content/tod.feed.rss.xml". There you can then make you own iterator to further specify which pages under the root page that should be listed. If you don't want any pages at all or just properties from the page itself you can implement that there as well. 

I might have missed something but if there are only things under the jcr:content it would be quite easy to just extract them from the page you are iterating over in your new overlay of the feed.jsp.
Either you overlay the feedentry.jsp as well and then you can change what goes into all the different elements such as:
 

<atom:entry id="<%= myCustomUrl %>" updated="<%= myCustomDate1 %>" published="<%= myCustomDate2 %>" > <atom:title><%= myCustomTitle %></atom:title> <atom:link href="<%= myCustomLink %>"/> <atom:content><%= myCustomContent%></atom:content> </atom:entry>


You could also have it in the same file i guess if you don't want to include the feedentry.jsp for the page. But that I guess is entirely up to you.

One heads up for working with these files is that they are VERY sensitive when it comes to line breaks and extra spaces that you are not allowed to have in your jsp files. 
You can read more about this in the KB article here : http://helpx.adobe.com/communique/kb/OutputStreamAlreadyObtained.html

 

Good Luck
/Johan

13 replies

smacdonald2008
October 16, 2015

Have you followed the documentation specified here: http://dev.day.com/docs/en/cq/current/wcm/web_syndication_feeds.html ?

October 16, 2015

I am not actually trying to display the feed on my site.  I would like to take the url http://localhost:4502/content/tod.feed.rss.xml and use it with feed burner.  Which the url returns the rss xml that I need.  However, I would like to change the values for the entry items link to a property I have set on the child pages and the pubDate to the lastModified date instead of using the creating date.  I thought I would be able to overwrite the feed.jsp and feedentry.jsp, more so the feedentry with these new values.

I would rather not use a list component to render the feed since I am storing references to other pages in my repository under the tod page.  This group of child pages will essentially be turned into an rss feed but at the same time I want to prevent the rss xml to use the childpages path since those pages will be hidden from the user.

<item>
<link>substitute with termPath property</link>
<comments>...</comments>
<guid>...</guid>
<title>../title>
<description>...</description>
<pubDate>substitute with lastModified date, not creation or publish date</pubDate>
<category />
<author>...</author>
</item>
Ojjis
OjjisAccepted solution
October 16, 2015

I was doing a similar thing.
It is possible to override  the "foundation/components/primary/cq/Page/feed.jsp" to control you own way of what should be included in the feed from the page that you "start from", in you case "/content/tod.feed.rss.xml". There you can then make you own iterator to further specify which pages under the root page that should be listed. If you don't want any pages at all or just properties from the page itself you can implement that there as well. 

I might have missed something but if there are only things under the jcr:content it would be quite easy to just extract them from the page you are iterating over in your new overlay of the feed.jsp.
Either you overlay the feedentry.jsp as well and then you can change what goes into all the different elements such as:
 

<atom:entry id="<%= myCustomUrl %>" updated="<%= myCustomDate1 %>" published="<%= myCustomDate2 %>" > <atom:title><%= myCustomTitle %></atom:title> <atom:link href="<%= myCustomLink %>"/> <atom:content><%= myCustomContent%></atom:content> </atom:entry>


You could also have it in the same file i guess if you don't want to include the feedentry.jsp for the page. But that I guess is entirely up to you.

One heads up for working with these files is that they are VERY sensitive when it comes to line breaks and extra spaces that you are not allowed to have in your jsp files. 
You can read more about this in the KB article here : http://helpx.adobe.com/communique/kb/OutputStreamAlreadyObtained.html

 

Good Luck
/Johan

Sham_HC
October 16, 2015

Try with [1] which includes jcr:content & it works. To avoid jcr:content in the url create a proxy  example Page.feed.jsp with text from [2].

[1]   http://localhost:4502/content/tod/jcr:content.feed.rss.xml

[2]    /libs/foundation/components/primary/cq/Page/proxy.jsp

April 11, 2017

I am facing one weired issue my feeds are working fine in author environment. But when i pushed the code to publish i am getting error "Cannot have a DOCTYPE declaration outside of prolog" Can someone please help me.

April 11, 2017

Sham HC wrote...

Try with [1] which includes jcr:content & it works. To avoid jcr:content in the url create a proxy  example Page.feed.jsp with text from [2].

[1]   http://localhost:4502/content/tod/jcr:content.feed.rss.xml

[2]    /libs/foundation/components/primary/cq/Page/proxy.jsp

 

I am facing one weired issue my feeds are working fine in author environment. But when i pushed the code to publish i am getting error "Cannot have a DOCTYPE declaration outside of prolog" Can someone please help me.

MC_Stuff
April 12, 2017

Hi Harsharya,

Response is not valid xml. Can you attach the response of feed?

Thanks,

April 12, 2017

Hi,

Please find the feed below.

<feed xmlns="http://www.w3.org/2005/Atom"><id>http://localhost:4503/comp/news0</id><updated>2017-04-11T07:01:19.028Z</updated><title type="html">
                              news
                       </title><generator uri="http://adobe.com/aem" version="6.1.SP1">Adobe Experience Manager</generator><entry><title type="html"> All you need to know about the new £1 coin</title><summary type="html">As the new pound coin enters circulation, find out what makes it ‘the most secure coin in the world’ and hear from the man responsible for getting it out to customers across the UK.</summary><id>http://localhost:4503/comp/news0/test1</id><published>2017-04-11T07:29:10.132Z</published><updated>2017-04-11T07:29:10.132Z</updated></entry><entry><title type="html"> Happy birthday to EU and goodbye - Economics Weekly</title><summary type="html">Sterling is down 12% since the referendum and some effects of its decline are becoming apparent.</summary><id>http://localhost:4503/comp/news0/harsh1</id><published>2017-04-11T07:29:11.688Z</published><updated>2017-04-11T07:29:11.688Z</updated></entry><entry><title type="html"> Happy birthday </title><summary type="html">Sterling is down</summary><id>http://localhost:4503/comp/news0/testing</id><published>2017-04-11T07:29:13.444Z</published><updated>2017-04-11T07:29:13.444Z</updated></entry><entry><title type="html"> All you need to know about the new £1 coin</title><summary type="html">As the new pound coin enters circulation, find out what makes it ‘the most secure coin in the world’ and hear from the man responsible for getting it out to customers across the UK.</summary><id>http://localhost:4503/comp/news0/testing1</id><published>2017-04-11T07:29:22.986Z</published><updated>2017-04-11T07:29:22.986Z</updated></entry><entry><title type="html"> All you need to know about the new £1 coin</title><summary type="html">As the new pound coin enters circulation, find out what makes it ‘the most secure coin in the world’ and hear from the man responsible for getting it out to customers across the UK.</summary><id>http://localhost:4503/comp/news0/testrss</id><published>2017-04-11T07:29:44.388Z</published><updated>2017-04-11T07:29:44.388Z</updated></entry><entry><title type="html"> Happy birthday to EU and goodbye - Economics Weekly</title><summary type="html">Sterling is down 12% since the referendum and some effects of its decline are becoming apparent.</summary><id>http://localhost:4503/comp/news0/testingrss</id><published>2017-04-11T07:29:56.457Z</published><updated>2017-04-11T07:29:56.457Z</updated></entry></feed>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
    <head><title>500 STREAM</title></head>
    <body>
        <h1>STREAM</h1>
        <p>Cannot serve request to /content/comp_com/en_uk/comp/news0.rss on this server</p>
        
        
        
        <hr>
        <address>ApacheSling/2.4 (jetty/9.2.9.v20150224, Java HotSpot(TM) 64-Bit Server VM 1.8.0_102, Linux 2.6.32-358.18.1.el6.x86_64 amd64)</address>
    </body>
</html>

July 28, 2017

Hi.

I am facing one issue. Its showing special characters when view source the feed generated by atom.

http://localhost:4503/content/geometrixx/en/products.feed

or just open the url in chrome.

December 4, 2017

Hi Harsharya,

I am  facing the exactly same issue. Can you  please guide how you fixed it.

Thanks in advance.

Regards,

Anjali