Author’s note: Tested only on Textpattern 4.0 – 4.0.2.
I was reminded in my last article that I had implemented clean RSS feeds on this site and never announced it or explained how it was accomplished. Truth be told, I thought that Jeremy Koempel would publish the code, since he basically handed it to me on a silver platter. Others may have done this before, and it may be published in other places, but the following is an explaination of how to achieve what I’d like to call Koempelized Clean Feeds™.
When I upgraded to TXP 4.0 from the release candidate, there were a lot of changes. Textpattern no longer operated sections off of cruft files, so previous clean feed solutions were broken. Being a PHP wuss, I whined about it a fair amount. Though he didn’t comment on it in that article, Jeremy emailed me a solution that was dead simple.
I should first point out that the main RSS feed for Textpattern sites—the one that aggregates articles from every section you choose to syndicate—did not require any trickery on my part. It worked right off the bat at http://www.jaredigital.com/rss.
The basic angle to Koempelized Clean Feeds is much like the old feed solution: move the feed code outside of the Textpattern installation. Here’s the breakdown:
Step 1: Create a new folder on your desktop. Name it whatever you want your feed to be named, e.g.
Step 2: Create a new PHP file inside your new folder called
index.php and paste in the following code:
- placeholder -
Step 3: Determine Textpattern’s path to your feed. Textpattern constructs paths to its feeds differently for sections and links. A full path to a section in our PHP file would be constructed as:
section_name would be replaced with the name of the section you want the feed to link to.
A full path to a link list in our PHP file would be constructed as:
your_category would be replaced with the name of the link category you want the feed to link to.
- placeholder - line in your
index.php code with either a path to your article section or links category as outlined above. So the full code for my links feed, for example, is:
Step 4: Upload your new folder to your site root. You can now access your clean feed by using the URL of your new folder!
This is a basic redirection tactic and there are surely other ways to accomplish it (.htaccess, anyone?). It may have also been done exactly in this way by someone else, but it worked so well for me that I figured others could benefit from it as well.
Once again, thanks go to Jeremy for introducing me to this solution.
Since we’re talking about feeds…
With my integration of the Loving… entries into a proper Textpattern section, those articles are being automatically rolled into the default RSS feed. If you think my taste in music and movies isn’t worth jack, or you’d rather not read my gushings about my latest favorite CD right alongside my regular articles, you can now pick and choose your feeds. Enjoy.