Last Friday, I got a request from one of our bloggers to have a means of getting a list of his posts. I thought that this couldn’t be that hard. I was slightly wrong. First, I thought I would do it all myself and use a direct connection to the database to get the data needed. But then I looked a bit closer at b2evo (the engine we use) and saw that it already had a link called archives and I thought that it would be easier to just change that.

So first I went on the lookout for the file that generated the archives and it turned out to be in the plug-ins folder called _archives.plugin.php. Cool. I just have to copy paste the file and rename it to _authors.plugin.php and I would have the code to work on and make the changes. Which I did, swiftly. It is all pretty reasonable and understandable. I just had to change some of the sql. But the code works for two things, one it is a widget and two it can be used to generate a page. So making the list of authors with how many posts they made was pretty easy. And then I noticed that the archives page is called by using a disp parameter namely ?disp=arcdir and that didn’t really work for ?disp=authdir. So I went to look for this variable. First I found a file in the skins folder named _arcdir.disp.php which seemed close enough for what I want. But that wasn’t enough I also had to add a little bit in the _skin.func.php file so that the new parameter would be accepted (I think they should change this and just scan the files in the skins folder called disp). All in all, it was pretty painless and the code is reasonably self-explanatory. Getting the right fields out of the database took some investigating but nothing I couldn’t handle.

So I think that writing a plug-in for b2evo could be a bit better and more streamlined but it is getting there.

You can find the source code in the b2evolution forums.

You can see the plug-in in action here and you can see the widget on the right menubar.

Apparently you can also do this in b2evo. But I don’t think I want our users to remember the user_Id of every author. But I think I can add it as an extra feature.