Comments on: Tag cloud alogrithm http://www.crazybobbles.org/2007/01/29/tag-cloud-alogrithm/ photos + music + geekery - mind games Thu, 20 Nov 2008 11:35:28 +0000 http://wordpress.org/?v=2.7-beta3-9762 hourly 1 By: Alex http://www.crazybobbles.org/2007/01/29/tag-cloud-alogrithm/comment-page-1/#comment-84 Alex Tue, 30 Jan 2007 12:02:47 +0000 http://www.crazybobbles.org/2007/01/29/tag-cloud-alogrithm/#comment-84 I used a similar calculation on my tag cloud I've just built for my new site... I get the following variables from the database: $max - the number of times the most popular tag has been used. $min - the number of times the least popular tag has been used. $distribution - ($max - $min) / 5; Then I just go through each tag from the database and select the CSS class for each one... Let's say that $tagcount is the amount of times a specific tag has been used... if($tagcount == $min){ $class = "link13"; /* smallest */ }elseif($tagcount == $max){ $class = "link28"; /* biggest */ }elseif($tagcount > ($min + ($distribution*2))){ $class = "link26"; /* big */ }elseif ($tagcount > ($min + $distribution)){ $class = "link20"; /* medium */ }else{ $class = "link15"; /* small */ } It's a bit quick and dirty but it works (so far) I used a similar calculation on my tag cloud I’ve just built for my new site…

I get the following variables from the database:

$max - the number of times the most popular tag has been used.
$min - the number of times the least popular tag has been used.
$distribution - ($max - $min) / 5;

Then I just go through each tag from the database and select the CSS class for each one…

Let’s say that $tagcount is the amount of times a specific tag has been used…

if($tagcount == $min){
$class = “link13″; /* smallest */
}elseif($tagcount == $max){
$class = “link28″; /* biggest */
}elseif($tagcount > ($min + ($distribution*2))){
$class = “link26″; /* big */
}elseif ($tagcount > ($min + $distribution)){
$class = “link20″; /* medium */
}else{
$class = “link15″; /* small */
}

It’s a bit quick and dirty but it works (so far)

]]>