Jump to content

[SOLVED] Help with tag cloud


defeated

Recommended Posts

Hi,

I have the following code making up a tag cloud.  I have just realised that it will not be limited... so if I have 1,000 tags they will all show.  Any ideas on how to modify it to limit the tags that show to 150?

 

Cheers

function tag_cloud() {

    $min_size = 9;
    $max_size = 30;

    $tags = tag_info();

    $minimum_count = min(array_values($tags));
    $maximum_count = max(array_values($tags));
    $spread = $maximum_count - $minimum_count;

    if($spread == 0) {
        $spread = 1;
    }

    $cloud_html = '';
    $cloud_tags = array(); // create an array to hold tag code
    foreach ($tags as $tag => $count) {
	$tag_url=str_replace(" ","-",strtolower($tag));
        $size = $min_size + ($count - $minimum_count) 
            * ($max_size - $min_size) / $spread;
        $cloud_tags[] = '<a style="font-size: '. floor($size) . 'px; line-height:'. floor($size+. 'px;' 
            . '" class="tag_cloud"  href="http://www.mynextjob.ie/tags/' . $tag_url 
            . '.jobs" title="' . $count . ' job(s) tagged \'' . $tag .'\'">' 
            . htmlspecialchars(stripslashes($tag)) . '</a>';
    }
    $cloud_html = join("\n", $cloud_tags) . "\n";
    return $cloud_html;

}

Link to comment
https://forums.phpfreaks.com/topic/172250-solved-help-with-tag-cloud/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.