Created
January 23, 2009 02:40
-
-
Save rafaeluzzi/50860 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php /* Hi from Puerto Rico | |
i am in love with sweetcron thanks yon for the toy. | |
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 pixelhttp://gist.github.com/images/modules/gist/paste_button.pngs | |
// 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; } */ ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment