Clean feed URLs in Textpattern

27 November 2004 @ really damn late | Comments (9)

14 March 2005 – There appear to be unresolvable problems with this from 1.0RC3 onward. More details available in this discussion.

05 January 2005 – Changed alphanumeric regular expression check syntax, as it wasn’t functioning properly with the \w shorthand. Now regex works as it should.

Forum discussion

I’ve been playing around with an attempt to create a non-hack method to accomplishing clean feed URLs in Textpattern, and I think I’m getting close. I really liked the method thought-up by mary in the Textpattern forum thread, Quick ‘n Easy Clean Feed Urls and was a bit inspired to solve the challenge presented by making it work for all types of feed requests.

This modification exists as a single file. It should be downloaded and renamed to ‘atom’ or ‘rss’, and reside in your desired directory with all of your other extensionless files. No modifications are needed to the file.

There are only a two small weaknesses that I can think of with this current version. First, it makes 1-2 additional database queries than the rss.php and atom.php if you’re requesting a section and a category. Second, it’ll become confused if you’re using categories and sections of the same name (something you really should avoid anyways).

So here are several example URLs:

  • http://domain.foo/rss/
  • http://domain.foo/rss/999/ (limit of 999 articles)
  • http://domain.foo/atom/link/5/ (limit of 5 links)
  • http://domain.foo/atom/photo/50/ (section ‘photo’ limit of 50)

I expect there to be some minor bugs and tweaks, but since this is totally running on existing Textpattern code, it should be totally safe. I’m sure there is some cruft in there that can be trimmed or optimized, but for now it is what it is. Please let me know your thoughts or if you see improvements that can be made.

random/txp/clean-feed-url.php.txt does not exist.


9 comments

1

That’s übercool! Thanks!

ChrisJ → hostinspace.com
2

Very nice… I really appreciate your work on this.

qrayg
3

Just implemented it last night and it’s brilliant!

Christopher → suburbanplayboy.com
4

Great! One wish, though: I’d like to choose the category of links to display in the /atom/link/ list. I tried /atom/link/linked_list/ but it didn’t show that category. Perhaps I’m doing it wrong?

Oskar Lissheim-Boethius → avocade.com/
5

I realize this post is a bit long in the tooth, but do you have any ideas about how to use this with RC3/no extensionless files?

Todd → auto.nomo.us
6

Todd, so you’re asking if you can use this extensionless setup for only your feed urls, while using messy urls for your site?

andrew → compooter.org
7

Looks like this might be a dead hack for the moment (see this thread). The good news is that clean feed links work out of the box, but only for certain schemas. Most of the flexibility that this method allows for has been disabled by certain architecture changes in TXP(Textpattern) since 1.0RC2.

andrew → compooter.org/
8

random/txp/clean-feed-url.php.txt does not exist.

Is this still available to download?

Elenita → penumbrae.com
9

It’s a no-longer functional semi-hack, due to structural changes introduced into the Txp core in 1.0RC3. Perhaps it’s possible as a plugin, but I currently have no plans on investigating the possibility. Sorry!

Andrew → compooter.org

Comments are closed for this article.

Previously