It all begins in with the {exp:weblog:entries} tag. Whenever we use the {exp:weblog:entries} tag we can use the {entry_id} variable to get the unique ID of a entry. When we have the entry ID, we can generate a URL to our ‘rsscomments' template. In that URL we will include the entry ID (example: http://www.domain.com/index.php/site/rsscomments/4535), in this case 4535 is our entry ID. Awaiting for us in the ‘rsscomments' template is a another {exp:weblog:entries} and a {exp:comment:entries} tag that will parse the necessary information for our feed.
We begin by creating a template inside a template group of your choice. Name your template; I named mine ‘rsscomments'. And the template type should be ‘RSS'. When you are ready paste the following code into your template:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
{exp:weblog:entries entry_id="{segment_3}" disable="categories|trackbacks|pagination|memberdata"}
<title>{exp:xml_encode protect_entities="yes" }{title}{/exp:xml_encode}</title>
<link>{title_permalink="templategroup/template"}</link>
<description>{exp:char_limit total="500"}{exp:xml_encode protect_entities="yes" }{summary}{/exp:xml_encode}{/exp:char_limit}</description>
{/exp:weblog:entries}
{exp:comment:entries orderby="date" entry_id="{segment_3}" sort="desc"}
<item>
<title>{exp:xml_encode protect_entities="yes" }Comment by {name}{/exp:xml_encode}</title>
<link>{exp:xml_encode protect_entities="yes" }{title_permalink="templategroup/template"}{/exp:xml_encode}</link>
<guid sPermaLink="false">{exp:xml_encode protect_entities="yes" }comment-{comment_id}{/exp:xml_encode}</guid>
<description>{exp:char_limit total="500"}{exp:xml_encode protect_entities="yes" }{comment}{/exp:xml_encode}{/exp:char_limit}</description>
<content:encoded><![CDATA[{comment}]]></content:encoded>
<dc:date>{gmt_comment_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
</item>
{/exp:comment:entries}
</channel>
</rss>
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
{exp:weblog:entries entry_id="{segment_3}"
disable="categories|trackbacks|pagination|memberdata"}
<title>{exp:xml_encode protect_entities="yes" }{title}
{/exp:xml_encode}</title>
<link>{title_permalink="templategroup/template"}</link>
<description>{exp:char_limit total="500"}
{exp:xml_encode protect_entities="yes" }{summary}
{/exp:xml_encode}{/exp:char_limit}</description>
{exp:comment:entries orderby="date" entry_id="{segment_3}" sort="desc"}
<title>{exp:xml_encode protect_entities="yes"}Comment by {name}
{/exp:xml_encode}</title>
<link>{exp:xml_encode protect_entities="yes"}
{title_permalink="templategroup/template"}{/exp:xml_encode}</link> <guid sPermaLink="false">{exp:xml_encode protect_entities="yes" }comment-{comment_id}{/exp:xml_encode}</guid>
In a normal feed our <guid> element would be also a permalink, but since this is a comment feed we need to choose another method to make our guid element unique, so we use the {comment_id}.
<description>{exp:char_limit total="500"}
{exp:xml_encode protect_entities="yes" }{comment}
{/exp:xml_encode}{/exp:char_limit}</description>
<content:encoded><![CDATA[{comment}]]></content:encoded>
<dc:date>{ gmt_comment_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
This
part is not that difficult, because it only involves making a hyperlink with a
entry ID in it. Like this:
<a href="{path=templategroup/rsscomments/{entry_id}}"
title="{title}">Comment RSS Feed</a>
{exp:weblog:entries weblog="myweblog"}
<H1>{title}</H1>
<p>{summary}</p>
<p>{extended}</p>
<a href="{path=templategroup/rsscomments/{entry_id}}" title="{title}">Comment RSS Feed</a>
{/exp:weblog:entries}
And voila! You got yourself a dynamic feed that will display comment for each entry you want. This method can also be applied for making a RSS feed for your gallery comments. You just have to replace the weblog tag with the gallery tag and use the appropriate variables. Success!