Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-01-27 11:15:14

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

[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

#2 2011-01-27 17:39:22

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

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)


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#3 2011-01-27 18:21:42

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

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

#4 2011-01-27 19:11:29

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: [howto] How-to : Generate a comments RSS feed


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#5 2011-01-27 20:12:40

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

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

#6 2011-01-28 16:03:02

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

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

#7 2011-01-28 16:36:43

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [howto] How-to : Generate a comments RSS feed

Nice tip Claire (and it involving rah_external_output, makes me feel warm and fuzzy) :-)

Offline

#8 2011-01-30 18:09:22

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,615
GitHub Twitter

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

Board footer

Powered by FluxBB