Category Archives: widget

Delicious Books

As some might have noticed, I have a “Recent Books” in my sidebar, and some might have wonders how it got there, well some time ago I decided to get a bit more handle on my books, as I started buying duplicates. Due to getting a license to DeliciousLibrary fairly cheap via MacHeist I choose to use that as library software, now what does on do when one have +800 books; there is the option of using a camera with ones Mac, but then again after a few books one figures out that this is not an option, so via ebay I found a cheap USB Barcode reader, and presto 3 days later all my books where in DeliciousLibrary. One thing I feel I have to mention; DeliciousLibrary is not perfect, far from, but it kind of works with all it quirks. And if your books isn’t in any Amazon shop, then you’ll have to manually add them.

Now that was cool, I had all my books in a database, well sort of, in a massive sqlite database, which kind of made things a bit difficult, I wanted to be able to 1) search my books, 2) be able to show off on my blog which books I recently had read, and 3) like to have access to my books via my iPhone…. 1) and 3) could be combined in one with a webpage, 2) was kind difficult, but possible. Now to do any of this I needed to have all my books in a usable database (I don’t really like sqlite), and after a bit of googling I found DeliciousSQLExport, and everything was bliss.

Next step was to create 1) and 3), massive headache which I’ll talk about some other time…..

But 2), well at that point my bloktheme was kind of customized, so add some php code and it was working, but there is a “small” issue with that, which is that if one wants to change theme, one is required to add custom code; which is not a good idea, as it becomes impossible to maintain (every developer should know that…), so I started looking in to writing a widget, and gave up again as the documentation was horrible.

A couple of days ago, I started researching the issue again, and found some good example which I could work with, and now have a widget which does what I want; it connects to a different data, does it query, and show it in the sidebar, what else could one ask for?

As I’m such a nice guy, I’ll let other people use it; download, create a deliciousbooks directory under wp-content/plugins, copy it there, and have a go at it.

And just to be even nicer;

title – what title the widget should have in the sidebar
show – how many books should be shown
db – database
dhHost – database host
dbUser – user which logs into the database host
dbPass – password for dbUser
dbTable – which table to query
amazonlink – http://www.amazon.
amazonadd – if you have something which needed to be added to the link, like if you for example get some a bit of money for referals add it here, it must end with ‘&’ (it don’t check this….)

Then it should show something in the sidebar. If it does not work, check your webservers error_log, look in the code, etc.

Please do not ask me for help, as it works for me, and that is it’s main purpose.