elliptical in OPML (version 2.0)

Hammered together the next version of the wp-opml.php template over the last day or so. This version shows the post links for the entire blog, within their respective categories. Categories are also properly nested. You can see the results here. The template file is available here. You could also browse the opml at Voidstar’s OPML Browser or at Randy Charles Morin’s OPML Surfer at KBCafe.

This version required a few extra functions – I placed those in a plug-in suitable file(cs_posts-by-category.php) which you can get here. It’s so named because 3 of the 4 functions might be suitable for other kinds of WP blog category/post uses as well.

I’m playing with the idea of serving up the entire contents of the blog in this fashion, but right now I’m thinking better of it; there’s a lot of data there. Perhaps something more like an RSS feed for that purpose, that limits itself to 30 posts or so. In any case, after I test this out on a few other renderers and double-check with the current thinking out there about proper use of OPML attributes, I’ll wrap it up in a more portable fashion.

Comments welcome.

It occurs to me that since there’s no other documentation yet, a brief description of how to use this is in order.

  1. Download the template file from http://kinrowan.net/development/WordPress/wp-opml.php.txt, rename it to wp-opml.php, and drop it somewhere in your WordPress directories. I placed mine in my WordPress Home directory, along side the wp-rss2.php template file.
  2. Download the plugin file from http://kinrowan.net/development/WordPress/cs_posts-by-category.php.txt and rename it to cs_posts-by-category.php. Place it in your plugins directory (%wp-home%/wp-content/plugins).
  3. go to your plugins admin page (http://%your-wordpress-address%/wp-admin/plugins.php) and activate the plugin.
  4. browse to the wp-opml.php file. Lo and behold – OPML!

Please contact me with comments or questions.

  • http://include.co.uk/blog/ Julius

    This looks great! A minor point – you might want to only display categories wich have posts assigned to them. Maybe.

    I did this by only pulling results back for categories that appear in the post2cat table.

    Also, how about having an option to publish post content, too?

    Thanks for putting this together. Very cool indeed.

  • http://kinrowan.net/ cori

    Thanks Julius,
    With respect to your minor point #1, I thought I was eliminating those records, but after typing a lengthy example I realized I was looking at the wrong query.

    I added a function to check for posts and suppress empty categories. Along the way I discovered a flaw in my handling of suppressing top-level display of child categories and added a function to handle that as well.

    While doing both of those, I realized that my flat handling of category nesting means that categories 2+ levels deep will also be suppressed; I need to design some recursion into my nesting functions to work that out.

    As far as your other comment goes, I’m still thinking about that. Currently I display links to every post, and generating the content for all of that would be a heavy load and a long process (in a template that already takes longer than I’d like). I’m thinking about adding some config options to the management dashboard for this purpose and am also thinking about making it a template tag instead of a standalone template – essentially wrapping the whole thing in a plug-in to make it a little less hack-y. Any feelings on that?

    The updated files are in the previously noted locations….

  • http://include.co.uk/blog/ Julius

    Thanks for the tweaks.

    Maybe full blog exports would be overkill after all.

    I suppose it depends on what the actual uses people make of OPML formatted feeds. Your solution gives a realy nice structured representation of the posts on the site, by category and title. This is great for spreading links around, like Dave is doing currently, and this may be the right model at the moment. If the need for full content feeds becomes clear, I don’t think it would be hard to add it, as you’ve already done the heavy-lifting.

    I have an interest in posts being actively reused in user-driven and collaborative ways, so full OPML interests me, as does the fact that they are less ephemeral than RSS.

    Thanks again.

  • http://jtintle.wordpress.com/ jtintle

    Great looking plugin so far. I had an idea close to this when a friend suggested I take a look at this. You see I was looking to create opml files from my actual posts. I was thinking about using or tags to designate what node I want the info placed in. You see at my site, I have been manually making OPML files for my posts, with a title, nodes under that are permalink, Image link, image credit, explanation, and tags/categories. And sorting them by date. I was wondering if you what you thought of the use of / tags to select the nodes?

  • http://kinrowan.net/ cori

    Hi John;
    Thanks – obviously it’s been dormant for a while but I’m thinking of picking up the thread and taking the next step (which I think is to truly plug-in-ify it, instead of this kind of manual architecture).

    Your idea of an opml file per post is an interesting one – while potentially increasing storage requirements (uless the blog itself is generated from the opml) it would certainly allow for an interesting remixbility as different people could use inclusion to generate an opml file of posts by many authors (on a side note I’d love to see the ability to include OPML from a sub-node of an OPML document instead of just the entire document). One thing I though of when looking at your OPML is that you ave 2 nodes marked with isComment=true and was curious why you chose that.

    As far as your question goes, I’m not sure what you mean by “the use of / tags to select the nodes”. Do you mean using tags to organize posts in the OPML? If so, I think of what I’m doing in the template that way, at least insofar as a post can belong to multiple categories and thus appear under multiple nodes within the OPML. Or am I misinterpreting what you mean?

  • http://jtintle.wordpress.com/ jtintle

    hi cori, first let me explain the comments in my blogs OPML, actually there are 3 nodes for with isComment=true, I just thought that using isComment=true looks better when parsed with an OPML browser, or like what I did at my test blog at http://jtintle.com/ No other real reason why.

    Now on to the tags I was thinking maybe using |div class=”explanation”| any explanation |/div| would be a good way to be able to create a node from html, especially if you are using php to parse it. I used the actual code earlier and your comments parsed them out is where the / tags came from

  • http://kinrowan.net/ cori

    Ah! So what you’re thinking is to use <div> elements in the html to parse into container <outline> nodes in the OPML, using the class html attribute to create the text opml attribute on a container node and then placing child <outline> nodes within them for each paragraph (similar to what the OPML Editor does).

    I think I have it now.

    Maybe this could be done with xslt. Hmm….