JavaScript must be enabled in order for you to use Google Maps. However, it seems JavaScript is either disabled or not supported by your browser. To view Google Maps, enable JavaScript by changing your browser options, and then try again.

Michael Tyler

KML Travel Blog

Tuesday, December 11, 2007

Blogger Tag Cloud Script

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)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#container {background:#d8d8ee; width:400px; margin:2px;
padding:2px; font-family:Arial}
.xsnazzy h1, .xsnazzy p {margin:0 10px; letter-spacing:1px;}
.xsnazzy h1 {font-size:2.5em; color:#fc0; text-align:center}
.xsnazzy p {padding-bottom:0.5em; color:#eee; text-align:justify}
.xsnazzy {background: transparent; margin:1em;}
.xsnazzy a:hover {color:#00FF00}
.xb1, .xb2, .xb3, .xb4, .xb5, .xb6, .xb7 {display:block; overflow:hidden;
font-size:0;}
.xb1, .xb2, .xb3, .xb4, .xb5, .xb6 {height:1px;}
.xb4, .xb5, .xb6, .xb7 {background:#ccc; border-left:1px solid #fff;
border-right:1px solid #fff;}
#michaeltyler {background:#7f7f9c; height: 12px;
border-left:3px solid #fff; border-right:3px solid #fff;
font-size:9px; position:relative; }
#michaeltyler div {position:absolute; top: 4px; width: 100%;
background-color: transparent; text-align:center; }
.xb1 {margin:0 8px; background:#fff;}
.xb2 {margin:0 6px; background:#fff;}
.xb3 {margin:0 4px; background:#fff;}
.xb4 {margin:0 3px; background:#7f7f9c; border-width:0 5px;}
.xb5 {margin:0 2px; background:#7f7f9c; border-width:0 4px;}
.xb6 {margin:0 2px; background:#7f7f9c; border-width:0 3px;}
.xb7 {margin:0 1px; background:#7f7f9c; border-width:0 3px; height:2px;}
.xboxcontent {display:block; background:#7f7f9c;
border:3px solid #fff; border-width:0 3px;}

</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<div id="container">
<div class="xsnazzy">
<b class="xb1"></b><b class="xb2"></b>
<b class="xb3"></b><b class="xb4"></b>
<b class="xb5"></b><b class="xb6"></b>
<b class="xb7"></b>
<div class="xboxcontent">
<h1>Chunky Borders</h1>
<p><?php
// 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 '<a href="/labels/'.$key.'"
style="font-size: '.$size.'%; font-weight: 200; "'; // change **
$delim = '.';
$page = substr($key, 0, strpos($key, $delim));
echo ' title="'.$page.'" >'.$page.'</a> ';
}
// end tag cloud

?></p>
</div><div id="michaeltyler"><div>
<a href="http://www.michaeltyler.co.uk">Michael Tyler - Tag Cloud</a>
</div></div>
<b class="xb7"></b><b class="xb6"></b>
<b class="xb5"></b><b class="xb4"></b>
<b class="xb3"></b><b class="xb2"></b>
<b class="xb1"></b>
</div>
</div>
</body>
</html>

Labels:

Links to this post

0 Comments:

Post a Comment

<< Home

Links to this post:

Create a Link