TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 18, 2024, 03:17:02 AM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 112
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 53
  • Total: 53

[Reguest] Tag Cloud snippet

Started by soMzE, February 28, 2007, 06:11:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

saks

This snippet is not work on SMF2 and last TP . How fix it ?

IchBin

Updated the code in the origin post on page to with code for SMF2. Let me know if it doesn't work.

saks

#102
it doesn't work :( Can be because i use Pretty URLs mod? But earlier all was good with Pretty too

I am use this code:
global $scripturl, $smcFunc;

$result = $smcFunc['db_query']('', '
SELECT t.tag AS tag, l.id_tag, COUNT(l.id_tag) AS quantity
FROM {db_prefix}tags as t, {db_prefix}tags_log as l WHERE t.id_tag= l.id_tag
GROUP BY l.id_tag
ORDER BY l.id DESC LIMIT {int:limit}',
array('limit' => 50)
);

$tags = array();
$tags2 = array();

while ($row = $smcFunc['db_fetch_assoc']($result))
{
$tags[$row['tag']] = $row['quantity'];
$tags2[$row['tag']] = $row['id_tag'];
}

$smcFunc['db_free_result']($result);

if(count($tags2) > 0)
{
// change these font sizes if you will
$max_size = 250; // max font size in %
$min_size = 100; // min font size in %

// get the 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 (0 == $spread)
{ // we don't want to divide by zero
$spread = 1;
}

// determine the font-size increment
// this is the increase per tag quantity (times used)
$step = ($max_size - $min_size)/($spread);

// loop through our tag array
$poptags = '';
$row_count = 0;
foreach ($tags as $key => $value)
{
$row_count++;
// calculate CSS 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 = $min_size + (($value - $min_qty) * $step);
// uncomment if you want sizes in whole %:
// $size = ceil($size);

// you'll need to put the link destination in place of the #
// (assuming your tag links to some sort of details page)
$poptags .= '<a href="' . $scripturl . '?action=tags;id=' . $tags2[$key] . '" style="font-size: '.$size.'%"';
// perhaps adjust this title attribute for the things that are tagged
$poptags .= ' title="'.$value.' things tagged with '.$key.'"';
$poptags .= '>'.$key.'</a> ';
if ($row_count > 5)
{
$poptags .= '<br />';
$row_count =0;
}
}
}
echo $poptags;

IchBin

I do not have the mod installed so I cannot test it. You saying "it doesn't work" does not give me anything to help you with. You need to give me any errors you may have in your SMF or server log. It would also help if you describe what doesn't work. Does it show a blank page? Does it not show anything? I need info if you want help.

saks

Quote from: IchBinâ,,¢ on September 17, 2011, 10:44:27 PM
I do not have the mod installed so I cannot test it. You saying "it doesn't work" does not give me anything to help you with. You need to give me any errors you may have in your SMF or server log. It would also help if you describe what doesn't work. Does it show a blank page? Does it not show anything? I need info if you want help.
Sorry !
In error log i do not have any errors for tags cloud. In main page block shows, but empty:

I am add in end of block code string echo 'test string'; , but it not shows

saks

Now I am test this block in clean install SMF+TP , and have this error:

IchBin

In your database, are the tag table rows named the same as in the query?

Is it still "ID_TAG"? Or is it now "id_tag"?

saks

in database on fresh install and in my working database - "id_tag" (small text)

saks

i am rename it in query but it not work ^(

IchBin

You must update all the columns that changed. l.ID is probably l.id now too. And don't forget in the php code there are references to ID_TAG as well. I've changed them all in the code above, see if it works.

Don't respond with "it don't work"... If it's not working you need to post errors from the SMF log or server error_log.