Making Tag Clouds with Turbogears
Tag Cloud? Yawn. So yesterdays news. Still, if you've never created one and you want to give it a whirl with Turbogears and SQLObject then here's some pointers.
First, thanks to this article which describes the process. I don't add much, I just give you some examples with Python, Kid and SQLObject.
Here the idea is pretty simple, I keep a table (SQLObject class) of gift categories and under each category a list of merchant sites that are in that category. If someone clicks on one of the merchant links I take the click and then redirect them to the merchant site (passing my affiliate code as I do so). Before I do the redirect though, I increment the number of clicks in the parent category.
So each category (Jewelery, Teddy Bears, Collectibiles) has a counter associated with it and that should determine it's size in the tag cloud. OK, some code :
The code to serve it up :
The klass value is going to link to a css class, the keyword class is reserved in python. Here are those classes (verbatim from Pete Freitag)
So now the Kid snippet to serve that lot up :
You know, this stuff is too easy. That's why I have a bit more styling on my tagcloud and I also added a bit of Ajaxy fun so that when you click a link it fills in an area below the tag cloud with all the merchants related to that category. Thank goodness for mochikit which makes that kind of thing pretty easy. Go ahead, try it.