Working out a category cloud

The category cloud above does work with a variable font-size for each item. The font size is related to the number of posts per category. Since some categories have up to 600 items while others only have two, I had to find a suitable scale. A good effect could be found by using a logarithmic value. So I used something like the following:

printf(\”<a href=\’/blog/p%s.html\’
  title=\’%s\’ style=\’font-size:%s;\’>%s</a>\”,
$row->cat_id,
$row->cat_name,
floor(log($row->items_per_cat) * 20) +100 .\”%\”,
$row->cat_name );

I preferred to chose this solution from having e.g. a switch with ranges of posts/category to point to different style classes like size1, size2, size3 etc.

Leave a Reply