Serendipity Template Update

If you read this site purely on a feed reader, this is probably irrelevant to you, but I recently made some changes to this blog and thought I’d post about how I worked with Serendipity to achieve them, mostly involving some template hacking and using a plugin to make a particular area of the site editable through the admin interface. Continue reading

Fixing Broken Serendipity Category

I migrated this blog to serendipity almost two years ago, and there have been a few things about it which have always driven me a bit mad. Many of these improved when I upgraded to version 1.4.1 of s9y but a few have persisted, including having two of my sidebar categories not display correctly. Where most of the categories behave as expected, two of of them just didn’t apply any filter at all and all my posts were visible on these pages.

I finally sat down today to diagnose the problem and discovered I was missing a record from the serendipity_permalinks table which was stopping s9y from being able to look up the id of the category. It was my craft category which is id 7 – all I had to do was run the following against mysql:

insert into serendipity_permalinks set permalink = "category/craft", entry_id=7, type="category";

So now my craft category works fine. If anyone knows how to stop my feeds from showing old articles as new when I edit them but don’t update the publication date, I’d be grateful! A bunch of imported posts are still missing their images, would be nice to be able to fix these without polluting my feed.

Serendipity and Feed Problems

This site uses a blogging platform called serendipity which is a nice little tool and I’ve been mostly happy since moving across from textpattern (I did write about the experience). Recently however, a few things have been going wrong with the feeds.

I edited an old post, because the image links were broken (I did have a nightmare migrating because I was so inconsistent about the format of the image tags in textpattern, completely my own fault). I was very careful not to update the published date of the article, however the edited article appeared in the feed, which wasn’t what I had in mind! It turned out that this is by design. On line 262 of includes/functions_entries.inc.php (I have serendipity 1.1.3), I found this:

$cond['orderby'] = 'last_modified DESC';

I’ve commented out this line, which was in an if($modified_since) clause. Hopefully this will stop updated entries from appearing in the feed – I have a few other old ones to fix images in so we’ll soon see.

At around the same time, Ivo mentioned that he was seeing the order of posts change in his reader (google reader) when people commented on my posts. I suspect that this is part of the same issue and I’m optimistic of it also being fixed by this change. However when I was looking into the problem I noticed that the URL he was using to access my feed, http://lornajane.net/index.rss2, actually returned RSS 0.91. Not ideal! The problem is the rewrite rule in serendipity’s .htaccess file, which looks like this:

RewriteRule ^(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml) rss.php?file=$1&ext=$2

When you request index.rss2 it should rewrite to rss.php?file=$1&ext=$2 but the “rss” matches first so the user gets redirected to index.rss instead. As a nasty hack to get around this I removed the rss from the above example and gave it a line of its own:

RewriteRule ^(index|atom[0-9]*|rss|b2rss|b2rdf).(rdf|rss2|xml) rss.php?file=$1&ext=$2
RewriteRule ^(index|atom[0-9]*|rss|b2rss|b2rdf).(rss) rss.php?file=$1&ext=rss

Requests to index.rss2 are now correctly rewritten as rss.php?file=index&ext=rss2 and will get RSS 2.0 format in the response. I have just noticed however that this is the most requested page on the site so I really hope I didn’t break anything!