Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-04-02 10:51:39

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

Hacking RSS/Atom feeds

I’m looking to squeeze more out of the RSS and Atom functionality of Textpattern. Currently, I use the built-in RSS generator to provide feeds based on the article section, like this:

http://example.com/rss?section=foo

Now, in the past, I’ve had reason to extend the functionality of RSS and achieved this by building my own feed with a page + form combo, along with mg_setheader to do the header stuff. This was fine for a single feed, but what I’d like to do is have a URL format akin to this:

http://example.com/rss?section=foo&expires=1&expired=0

…attributes a bit like article_custom, in fact. What I’d ideally like to avoid is having to make a page + form combo for each of the sections I want to have this functionality; having one page + form to do this, with the URL specifying the article_custom attributes is what I’m aiming for. Is such a thing possible?

Thank you in advance.

Offline

#2 2013-04-02 11:01:03

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

Re: Hacking RSS/Atom feeds

This could work:

<txp:etc_query globals="_GET">
   <txp:article_custom
       {$?({?section}|section="{?section}"|)}
       {$?({?expired}|expired="{?expired}"|)}
       ... other attributes ...
   />
</txp:etc_query>

More details here.

Edit: small typo fix (expires=>expired), sorry.

Last edited by etc (2013-04-02 11:52:46)

Offline

#3 2013-04-02 11:03:35

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

Re: Hacking RSS/Atom feeds

Oleg, that’s great – thank you very much.

Offline

#4 2013-04-02 11:14:36

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

Re: Hacking RSS/Atom feeds

You are welcome, Pete! Actually, if you have adi_gps installed, retrieving url data with adi_gps and

<txp:article_custom
       <txp:if_variable name="section">section='<txp:variable name="section" />'</txp:if_variable>
       ... other attributes ...
/>

should work too (untested). I have etc_query installed on every site, so it’s kind of Pavlov reflex for me.

Last edited by etc (2013-04-02 11:15:04)

Offline

#5 2013-04-02 11:41:26

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

Re: Hacking RSS/Atom feeds

I’ll give both a try, Oleg – thank you again for your quick response.

Offline

#6 2013-04-02 12:22:42

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

Re: Hacking RSS/Atom feeds

The second solution is based on the controversial secondpass feature though – might be not perennial.

Offline

#7 2013-04-03 01:36:12

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Offline

#8 2013-04-03 08:59:26

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

Re: Hacking RSS/Atom feeds

Thanks, Michael – I’ll take a look.

Offline

Board footer

Powered by FluxBB