Hi,
I wonder if anyone could advice a complete novice? I’m looking to limit the number of tags displayed on my website. As it stands the number is limitless and I’m having to delete the tags everyday in phpmyadmin.
I’ve ran dozens of searches on Google and have tried various snippets of code, all to no avail.
TIA
[php]// ------------------------------------------------------------------------
;
class Lib_TagClouds
{
function displayTagClouds($tags,$onClick=’’)
{
$res=’’;
if(!(empty($tags)))
{
//ksort($tags);
$max_size = 30; // max font size in pixels
$min_size = 10; // min font size in pixels
// largest and smallest array values
$max_qty = max(array_values($tags));
$min_qty = min(array_values($tags));
// find the range of values
$spread = $max_qty - $min_qty;
if ($spread == 0) { // we don't want to divide by zero
$spread = 1;
}
// set the font-size increment
$step = ($max_size - $min_size) / ($spread);
// loop through the tag array
foreach ($tags as $key => $value) {
// calculate font-size
// find the $value in excess of $min_qty
// multiply by the font-size increment ($size)
// and add the $min_size set above
$size = round($min_size + (($value - $min_qty) * $step));
$res.= '<a href="'.$onClick.$key.'" style="text-decoration:none; font-size: ' . $size . 'px" title="' . $value . ' times searched." >' . $key . '</a> ';
}
}
return $res;
}
}
?>
[/php]