Sie sind auf Seite 1von 2

<?

php /*Hi from Puerto Rico


sweetcron is an open source lifestream app built with the codeigniter php
framework.

i just made a nice tag cloud if anyone is intreted here it is.


this uses $popular_tags and it displays tags with greater counts
bigger in size and so on..

paste this to _sidebar.php replacing the original tag list code*/ ?>

<h3>Popular Tags</h3>
<?php
function printTagCloud($tags) {
// $tags is the array

arsort($tags);
//adjust to your liking
$max_size = 10; // max font size in pixels
$min_size = 8; // 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 $tag) {
$name=$tag->slug;
$count=$tag->count;
// calculate font-size
// find the $count in excess of $min_qty
// multiply by the font-size increment ($size)
// and add the $min_size set above
$size = round($min_size + (($count - $min_qty) *
$step));
echo '<li><a href=" '. $url . '/items/tag/', $name . '
" style="font-size: ' . $size . 'px"
title="' . $count . ' things tagged with ' . $name . '">'
. $name .
'</a></li> ';

}
}
$tags= $popular_tags;
$Url= $this->config->item('base_url')
?>

<ul class="tag_list">
<!-- BEGIN Tag Cloud -->
<?php printTagCloud($tags); ?>
<!-- END Tag Cloud -->
</ul>

<?php /*now here is some css that can be used with this

add to main.css

ul.tag_list li {
display: inline;
margin-right: 3px;
padding: 3px; text-decoration: none;
}
ul.tag_list li :link { color: #81d601; }
ul.tag_list li :visited { color: #019c05; }
ul.tag_list li :hover { color: #ffffff; background: #69da03; }
ul.tag_list li :active { color: #ffffff; background: #ACFC65; } */?>

Das könnte Ihnen auch gefallen