Blogger Tag Cloud Script

Blogger Tag Cloud Script

Share on social media

Being bored on a Monday morning, I wrote this script.

Its’ for bloggers with an FTP account, (non-blogspot account), this tag cloud will read the contents of your ‘labels’ folder and create a formatted cloud of links based on file sizes and category headings.

Blogger Tag Cloud Script – (php server – php 4 or higher)

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">




Untitled Document










Chunky Borders


// php tag cloud - blogger ftp accounts tag cloud for labels folder.
// The tag cloud automatically takes the contents of your labels folder,
// reads the files and gives the values according to the number of posts.
// Change the 'labels' location marked.
// Please leave my little marker at the bottom. Thanks.

$handle = opendir('../labels/'); // change **
if (!empty($handle))
{
while (false !== ($page = readdir($handle)))
{
if ($page != "." && $page != "..")
{ $filesize = filesize('../labels/'.$page); // change **
$labels[] = array ("page" => $page, "filesize" => $filesize); }
}


}
// tag cloud functionality ===
foreach ($labels as $key => $value){
$tags[$value["page"]] = $value["filesize"];
}

$max_size = 180; // max font size in %
$min_size = 58; // min font size in %


$max_qty = max(array_values($tags));
$min_qty = min(array_values($tags));


$spread = $max_qty - $min_qty;
if (0 == $spread) {
$spread = 1;
}


$step = ($max_size - $min_size)/($spread);

foreach ($tags as $key => $value) {
$size = $min_size + (($value - $min_qty) * $step);

echo 'style="font-size: '.$size.'%; font-weight: 200; "'; // change **
$delim = '.';
$page = substr($key, 0, strpos($key, $delim));
echo ' title="'.$page.'" >'.$page.'
';
}
// end tag cloud

?>











2 thoughts on “Blogger Tag Cloud Script

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.