Speaking of OPML…

… and of Dave

I’ve seen Dave talking a lot about browsing blog posts via OPML. I like OPML for a lot of purposes (subscription lists, reading lists, almost any kind of list, outlines), but don’t get Dave’s big picture vision yet. That said, I like the idea of being able to include blog posts in an outline, so I wrote a Wordpress template to output OPML for blog post links. You can get the template here and can see my OPML here.

A few notes:

  1. the template currently uses the blog’s feed post quantity setting
  2. it doesn’t organize the posts by category - it’s basically just an RSS feed in OPML with just the links to the posts.
  3. I just dropped the file in my wp directory for it to work. It should be as simple as that, though if the format of it gets more complicated a plug-in might be worthwhile.

In reference to #2 above, it’s not that useful yet, but it’s a start. I didn’t know off-hand of a built-in WP function to loop through the categories of a blog and allowed me to insert code for each record, and I only had a few minutes to put this together. I’ll look around for something that does what I need, and failing that will write one myself. If you know of something, please post in the comments.

I’d love to have this actually wrap the entire blog post in OPML, much the way that Dave’s OPML Editor writes blog posts (i.e. wrapping each paragraph in it’s own <outline> tag). In fact, I played around for a while with making OPML Editor able to post to this blog when I wanted it to, but couldn’t get the XML-RPC calls to work properly (for those who may care, I couldn’t authenticate to the blog, even though I’m confident the username/password were correct), so I put that on hold for a while.

Comments of any sort (including constructive “What a stupid idea” or “Your code sucks” comments) are welcome.

6 Responses to “Speaking of OPML…”

  1. Julius Says:

    Hi. I did something similar myself a few days back. This produces OPML with posts nested by category, but the SQL needs a tweak to allow posts to appear as many times as they have categories applied to them - currently a post only appears once, regardless of the number of categories, which is a problem.

    Your approach is clearly much more “Wordpress-like” than mine, which is great.

    I’ll keep an eye out for new versions of your template.

    Thanks!

  2. Julius Says:

    Ooops! I forgot the link:
    http://www.include.co.uk/blog/?p=296

  3. Firmly Wedged » Wordpress OPML Says:

    […] t all adds up, you know. Thanks. Update: I’m not the only person trying to do this. Eliptical has posted a template which produces all posts as OPML, but as yet th […]

  4. cori Says:

    Hey Julius;

    I’ve got the category and recursion stuff orked out in my head pretty well for the nested category thing as well, and I think it’ll allow multiple categories per post. I also think it’ll nest the categories acurately - we’ll see when I have it coded on the server. Actually, it’s halfway into the file on the server, which is why that file produces “Parse error: parse error, unexpected T_GLOBAL, expecting ‘{’ in /wp/wp-opml.php on line 42″. (now fixed)

    I have not dealt with invalid characters, as I see you’ve done. I’ll add that to my ToDo.

    Thanks for stopping by!

  5. Julius Says:

    Great stuff. No doubt I’ll be dumping my code shortly and moving to yours.

    Special characters - Yes, they do need to be escaped. There must be a PHP or WordPress function for this, so it shouldn’t be too hard to implement without having to list each character specifically. urlencode may actually do this, but I’m not sure. I may have a play with this myself.

  6. Julius Says:

    Urlencode looks a bit “slash and burn” - encoding every space, for example. I’m sure I’ve seen somthing that selectively swaps in ’safe’ characters somewhere.

    Also, it looks like items are appearing in each applied category in my output after all, so I’ve actually got a propoer OPML feed, which is cool. I still want to move to a WP friendly version, though. Mine’s not really that simple to implement on a any random Wordpress weblog.

Leave a Reply