Just a short modification if you want to show popular tags from last week / months or year:
Modify STEP2 from:
//---[ [MOD] Tag Cloud]
function get_tag_clouds() {
global $site_db, $lang, $site_sess, $mode;
$output = "";
$sql = "SELECT i.word_id, i.word_text, COUNT(c.word_id) AS quantity
FROM ".WORDLIST_TABLE." i
LEFT JOIN ".WORDMATCH_TABLE." c ON i.word_id = c.word_id
WHERE keys_match > 0
GROUP BY i.word_text
ORDER BY RAND()
LIMIT 20";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$tags[$row['word_text']] = $row['quantity'];
}
//uncommentnext line to sort the tag array in reverse order (+ => -)
//arsort($tags);
$max_size = 250; // max font size in %
$min_size = 50; // min font size in %
// 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 $key => $value) {
// calculate font-size
// find the $value in excess of $min_qty
// multiply by the font-size increment ($size)
// and add the $min_size set above
$size = round($min_size + (($value - $min_qty) * $step));
$output .= '<a href="'.$site_sess->url(ROOT_PATH."search.php?search_keywords=".$key.((!empty($mode)) ? "&mode=".$mode : "")).'" style="font-size:'.$size.'%;color:rgb('.mt_rand(0, 255).', '.mt_rand(0, 255).', '.mt_rand(0, 255).');font-family:Verdana, Arial, Helvetica, sans-serif;" title="'.$value.' '.$lang['tagged_with'].' '.$key.'">'.$key.'</a> ';
}
return $output;
}
//---[/[MOD] Tag Cloud]
To:
//---[ [MOD] Tag Cloud]
function get_tag_clouds() {
global $site_db, $lang, $site_sess, $mode;
$output = "";
$sql = "SELECT w.word_id, w.word_text, c.image_id, i.image_date, COUNT( c.word_id ) AS quantity
FROM ".WORDLIST_TABLE." w
LEFT JOIN ".WORDMATCH_TABLE." c ON w.word_id = c.word_id
LEFT JOIN ".IMAGES_TABLE." i ON c.image_id = i.image_id
WHERE keys_match >0
AND i.image_date >= ".(time() - 60 * 60 * 24 * 7)." // 7 means 7 days, if you want to show popular tags from last months replace 7 with 30, for last year 365
GROUP BY w.word_text
ORDER BY quantity DESC
LIMIT 20";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$tags[$row['word_text']] = $row['quantity'];
}
//uncommentnext line to sort the tag array in reverse order (+ => -)
//arsort($tags);
$max_size = 250; // max font size in %
$min_size = 80; // min font size in %
// 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 $key => $value) {
// calculate font-size
// find the $value in excess of $min_qty
// multiply by the font-size increment ($size)
// and add the $min_size set above
$size = round($min_size + (($value - $min_qty) * $step));
$output .= '<a href="'.$site_sess->url(NUKE_PATH."search&search_keywords=".$key.((!empty($mode)) ? "&mode=".$mode : "")).'" style="font-size:'.$size.'%;color:rgb('.mt_rand(0, 255).', '.mt_rand(0, 255).', '.mt_rand(0, 255).');font-family:Verdana, Arial, Helvetica, sans-serif;" title="'.$value.' '.$lang['tagged_with'].' '.$key.'">'.$key.'</a> ';
}
return $output;
}
//---[/[MOD] Tag Cloud]
Note: AND i.image_date >= ".(time() - 60 * 60 * 24 * 7)." // 7 means 7 days, if you want to show popular tags from last months replace 7 with 30, for last year 365