Php Blok olu?turup, içine kodlar? ekleyiniz.
// Simple Tagging Cloud | Simple Tagging Etiket Bulutu
global $context, $smcFunc, $modSettings,$txt, $scripturl;
$context['tags'] = array();
$result = $smcFunc['db_query']('', '
SELECT t.tag_name, COUNT(tt.id_tag) AS amount
FROM {db_prefix}tags AS t
INNER JOIN {db_prefix}tag_topics AS tt ON (tt.id_tag = t.id_tag)
GROUP BY tt.id_tag
LIMIT {int:limit}',
array(
'limit' => $modSettings['tags_to_show']
)
);
while ($row = $smcFunc['db_fetch_assoc']($result)) {
$tags[$row['tag_name']] = $row['amount'];
}
$smcFunc['db_free_result']($result);
// Let's shuffle these puppies up, to make it more fun
$keys = array_keys($tags);
shuffle($keys);
foreach ($keys as $key)
$context['tags'][$key] = $tags[$key];
$context['max_size'] = (int) $modSettings['max_tag_percentage'];
$context['min_size'] = (int) $modSettings['min_tag_percentage'];
$context['max_qty'] = (int) max(array_values($context['tags']));
$context['min_qty'] = (int) min(array_values($context['tags']));
$spread = $context['max_qty'] - $context['min_qty'];
$spread = ($spread > 0) ? $spread : 1;
$context['step'] = ($context['max_size'] - $context['min_size']) / $spread;
// I'm settings this here so that you can change it on a per-theme basis
$context['tag_colors'] = array(
'#0AC92B', // Green
'#CC00FF', // Purple
'#FF0033', // Red
'#4D4DFF', // Blue
'#000000', // Black
);
$num_colors = count($context['tag_colors']) - 1;
if(!empty($context['tags']))
foreach ($context['tags'] as $key => $value){
$color = $context['tag_colors'][mt_rand(0, $num_colors)];
$size = ceil($context['min_size'] + (($value - $context['min_qty']) * $context['step']));
// The index is so we can put smaller elements in front, so they won't get swallowed by the big ones.
$index = abs($size - $context['max_size']);
echo '<a href="', $scripturl, '?action=tags;name=', urlencode($key), '" style="z-index: ', $index, '; position: relative; font-size: ', $size, '%; color: ', $color, ';" title="', $value, ' ', $txt['tags_tagged_with'], ' ', ucwords($key), '">', str_replace(' ', ' ', ucwords($key)), '</a> <span class="smalltext">(', $value, ')</span> ';
}
else
echo $txt['tags_none_in_cloud'];