Hi all,
Because nothing easy was ready to be install to have a community tag could using last Wordpress 1.3 tags, I've added a new function in wpmu-functions.php
Read the code on my blog, or at the end of this post.
Please tell me what you think of it, and if you find any bugs.
Cheers,
Alex
function get_community_tag_cloud( $display = false, $limit = 50, $font_size = 20 ) {
global $wpdb;
// Get all blogs
$sites = $wpdb->get_results( "SELECT blog_id FROM wp_blogs", OBJECT);
$array_tags = array();
// Set category to not display, usually 'Uncategorized'
$no_category = "Sin Categorizar";
foreach($sites as $site){
$table_tags = "wp_".$site->blog_id."_terms";
$table_taxonomy = "wp_".$site->blog_id."_term_taxonomy";
if($exists = $wpdb->get_row("show tables like '$table_tags'")){
// Get name and count for each post_tag
$tag_results = $wpdb->get_results("SELECT name, count FROM $table_tags INNER JOIN $table_taxonomy ON $table_tags.term_id = $table_taxonomy.term_id WHERE $table_taxonomy.taxonomy LIKE 'post_tag'");
foreach ($tag_results as $tag) {
if( strlen($tag->name) > 0 and $tag->name != $no_category){
// Increment count of this tag
$array_tags[$tag->name] += $tag->count;
}
}
}
}
// Sort tag array by 'popularity'
arsort($array_tags, SORT_NUMERIC);
// Limit size if necessary
if(count($array_tags) > $limit){
$array_tags = array_slice($array_tags, 0, $limit);
}
// Display options
if( $display == true ){
if( is_array( $array_tags ) ) {
reset( $array_tags );
echo "<div id='tag_cloud'>";
foreach ( (array) $array_tags as $name => $count ) {
$url = get_site_option('url')."/tags/$name";
echo "<span style='font-size:".$font_size."px'><a href='$url'>$name</a></span> ";
if($font_size > 8){
$font_size--;
}
}
echo "</div>";
}
}
return $array_tags;
}