Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[howto] How-to : Generate a comments RSS feed
Edit: see below for a better tip
Why this post ?
I recently wanted to set up a comments RSS feed. I’ve been lurking in the forum, finding pieces of information but – forgive me if I haven’t seen it – didn’t found step-by-step instructions.
That’s what I would like to share here.
Credits mostly and heavily go to makss because following his instructions HowTo: Create and customize your own RSS feeds really did the main part of the work.
What is needed- The plugin aks_header
- Name of the comment’s author will have to be alone (i.e. without any links), I use etz_striptags to achieve this
Disclaimer and limitations
The usual one : this worked for me but there’s absolutely no warranty it won’t break your site :)
I will cover here the case of a RSS Feed, not an Atom Feed.
Additionally, if you find that the following codes could be better, suggestions are welcome.
Let’s stop chatting and work, here is what I did (follow in parallel makss’ instructions) :
Step 1
Install and activate aks_header
Install and activate etz_striptags
Step 2
Create the “rssfile” template with the following content :
<txp:aks_header name="Content-Type" value="application/rss+xml" strip="0" gzip="1" nodebug="1" /><?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><txp:site_name /></title>
<description><txp:site_slogan /> - comments</description>
<link><txp:link_to_home /></link>
<atom:link href="<txp:link_to_home /><txp:page_url type="s" />/" rel="self" type="application/rss+xml" />
<pubDate><txp:php>echo safe_strftime('rfc822');</txp:php></pubDate>
<txp:article><txp:body /></txp:article>
</channel>
</rss>
Step 3
Create the section “mrss” as mentioned
Step 4
Exclude “mrss” from sitemap (I took this option)
Step 5
Create an form named “rss_custom”, type article, with the following content :
<item>
<txp:variable name="item_content" value='<![CDATA[<txp:comment_message />]]>' />
<txp:variable name="item_author" value='<txp:etz_striptags><txp:comment_name /></txp:etz_striptags>' />
<title>Commentaire sur <txp:title no_widow="0" /> par <txp:variable name="item_author" /></title>
<txp:php>
global $thiscomment;
echo tag( permlinkurl($thisarticle).'#c'.$thiscomment['discussid'], 'link' )
.n.
tag( permlinkurl($thisarticle).'#c'.$thiscomment['discussid'], 'guid' ) ;
</txp:php>
<pubDate><txp:comment_time format="rfc822" /></pubDate>
<description><txp:variable name="item_content" /></description>
<content:encoded><txp:variable name="item_content" /></content:encoded>
<dc:creator><txp:variable name="item_author" /></dc:creator>
</item>
Step 6
Write an article as makss mentions, except that the URL-only title is not important in this case, the body containing :
<txp:recent_comments form="rss_custom" break="" />
Optional Step 7
You can put in the head of all the other pages
<head>
<link href="<txp:site_url />rss_custom/" title="Comments RSS Feed" type="application/rss+xml" rel="alternate">
</head>
Step 8
Your feed should accessible via http://www.example.com/rss_custom/
Hope this helps !
Last edited by CeBe (2011-01-28 16:14:24)
Offline
Re: [howto] How-to : Generate a comments RSS feed
You could use rah_external_output instead of a section, an article and aks_header
This would make a great tip for TxpTips.com.
Last edited by MattD (2011-01-27 17:51:35)
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
Re: [howto] How-to : Generate a comments RSS feed
MattD a écrit:
You could use rah_external_output instead of a section, an article and aks_header
Hah huh … well … I have to confess that I didn’t understand how Jukka’s plugin works. I’m probably missing something.
This would make a great tip for TxpTips.com.
Thank you, but the same using rah_external_output could be a greater tip, and I’m curious to see this. Any volunteer ? :-P
Offline
Re: [howto] How-to : Generate a comments RSS feed
Take a look at my TxpTip on creating an author feed.
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
Re: [howto] How-to : Generate a comments RSS feed
Interesting. Very interesting.
Going to throw the children in bed then have a look at it.
Thank you !
ETA : Tried. It’s way more elegant and efficient. TXP Tips is a must-read.
Last edited by CeBe (2011-01-27 21:49:21)
Offline
Re: [howto] How-to : Generate a comments RSS feed
MattD a écrit:
This would make a great tip for TxpTips.com.
Done
You were a great help, many thanks !
Offline
Offline
Re: [howto] How-to : Generate a comments RSS feed
A new Tip from… France ;)
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline