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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 210
  • Total: 211
  • @rjen

[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.

FragaCampos

#90
Here i am once more :)

I noticed that when we click on a tag it doesn't redirect us to the correspondent tagged topics, as it happens with the tagcloud of the original mod.

I noticed that the link for the topics tagged with a certain word is as follows:
http:/mysite/index.php/action,tags/tagid,132.html

And the links from the tagcloud block is:
http:/mysite/index.php/action,tags/id,132.html

I believe this is the problem, any ideas on how to fix this?
Thanks.


Edit: I found the solution. I changed
$poptags .= '<a href="' . $scripturl . '?action=tags;id=' . $tags2[$key] . '" style="font-size: '.$size.'%"';

to

$poptags .= '<a href="' . $scripturl . '?action=tags;tagid=' . $tags2[$key] . '" style="font-size: '.$size.'%"';

It worked  :)

JPDeni

 :up: Good for you for working it out.

FragaCampos

Sorry to dig this up, but i saw something in another blog that i would like to see with this snippet.
Is there any chance to attribute different colours to the tags like in here?

Thanks in advance.

Phantom

someone have code for Tag Cloud (from Tagging System http://custom.simplemachines.org/mods/index.php?mod=579 ) to display it in block ?

sorry for my english..

WillyP

Have you tried the code from earlier in this post?

Phantom

yes, i tried this code:

global $db_prefix, $scripturl, $txt;
$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 RAND() LIMIT 50";

$result = db_query($query, __FILE__, __LINE__);

$tags = array();

$tags2 = array();

while ($row = mysql_fetch_array($result))
{
    $tags[$row['tag']] = $row['quantity'];
    $tags2[$row['tag']] = $row['ID_TAG'];
}

if(count($tags2) > 0)
{
// change these font sizes if you will
$max_size = 250; // max font size in %
$min_size = 95; // 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;tagid=' . $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 > 6)
   {
    $poptags .= '<br />';
    $row_count =0;
   }
}
}
echo "<center>" . $poptags . "</center>";


and it does not work (i use SMF 2.0RC3 and TP 1.0RC1) :/

IchBin

Replace all instances of db_query with tpdb_query

Phantom


WillyP

Cool, I'll probably add this to my own site!  Should we add this to the snippet index?

IchBin

Feel free to add anything to the snippets index.

This website is proudly hosted on Crocweb Cloud Website Hosting.