| Services | About BN | Clients | Projects | Widgets | Blog | Contact BN |

95 - How I implemented my blogroll in PHP for Wordpress - plug-in BETA code available

I just finished up the last of the big tasks I had for my implementation of my Blogroll. I may have been able to tweak the link sinterface in Wordpress to do this, but I had some specific reasons for implementing it separately; the biggest reason being that I use my .opml file for multiple purposes, and having to re-import it into any of those programs regularly is just a pain in the ass.

My Pocket PC reader uses my .opml dynamically, and my Wordpress install uses it dynamically as well (well, it does now…)

The next step is to make this a Wordpress plug-in. Shoot me your comments and I’ll use them before releasing to the Wordpress community at large.

First, you need an OPML file. Mine can be found in the list of links at the top right corner. I don’t use the text field, but it should work as a backup, although I have yet to test it that far. Feel free to use it as a base, but please download it first, don’t deep link it.

Next, you need the include file blogroll.php (linked here as a text file for download). I put it in a directory called bn-includes at the root of my wordpress install point. This file is the meat of it all. It reads your .opml file, parses it, sorts it, and then displays it with a separate link for the feed and the URL of the site. The feed is linked off of the xmlButton, and the site’s URL is linked off of either the title or the text for that specific entry.

Finally, you call the blogroll.php as such:

<li id="blogroll">Blogroll
 	<ul>
 		<?php
		 require("bn-includes/blogroll.php");
		 blogroll("/full-path-to-file-here/myChannels3.opml")
		 ?>
	</ul>
 </li>

It will display the text in your .opml as a blogroll like on mine, using your current .css

Caveats:
1) It’s not 100% done yet, so there are cases that are not covered, such as what happens if the xmlURL and or URL field are blank?
2) There are no comments
3) Sorting is weird and not fixed yet. It will sort capitalized and non-capitalized separately. This should be an easy fix, but for some reason, my install of PHP was not letting the other sort functions work properly, so I passed on it for now and just tweaked my titles to all be capitalized.

Feel free to try it out and give me feedback here as a comment. I’ll take all advice to heart and integrate most of it in as fixes, and then release it as a Wordpress plug-in.


No Comments yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment