Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

September 28, 2022, 06:49:29 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 193513
  • Total Topics: 21092
  • Online today: 91
  • Online ever: 3540
  • (September 02, 2022, 06:38:54 PM)
Users Online
Users: 0
Guests: 79
Total: 79

Author Topic: [Reguest] Tag Cloud snippet  (Read 72316 times)

0 Members and 1 Guest are viewing this topic.

JPDeni

  • Guest
Re: [Reguest] Tag Cloud snippet
« Reply #10 on: March 01, 2007, 07:06:12 AM »
Well, now don't I feel like a doofus?  :uglystupid2:

After working on your site for a little bit, I found the problem. There was no command to actually print them out.  :2funny:

I've added the right code to your site and edited it here for others to use.

Blame it on the migraine. Yeah, that's it!!  ::)

soMzE

  • Guest
Re: [Reguest] Tag Cloud snippet
« Reply #11 on: March 01, 2007, 07:20:38 AM »
YOUR AWESOME!!!  ;D It looks really cool!! Me so happy now haha, don't know what to say.. my first request here, it's a special day today LOL

And to bad you have these migraines JPDeni, it's not nice.. but still, you're great!  ;D

If others are to use this code, to reduce the number of populair tags change:

Code: [Select]
ORDER BY l.ID DESC LIMIT 25";

Can't thank you enough!!  :laugh:




JPDeni

  • Guest
Re: [Reguest] Tag Cloud snippet
« Reply #12 on: March 01, 2007, 07:27:45 AM »
LOL! Well, I'm glad I figured it out and I'm glad you are happy with the results. It does look cool.

The migraines aren't fun, to be sure, but I'm used to them. They just sorta get in the way of thinking sometimes.

soMzE

  • Guest
Re: [Reguest] Tag Cloud snippet
« Reply #13 on: March 01, 2007, 07:57:15 AM »
Yes i'm really happy with the results!  :)

One question, when i reduce the number of tags in the snippit, this also affects the main page of Tag Modification, is there a way to only reduce them in the block?  :)
« Last Edit: June 16, 2008, 04:54:06 AM by soMzE »

JPDeni

  • Guest
Re: [Reguest] Tag Cloud snippet
« Reply #14 on: March 01, 2007, 08:06:16 AM »
I think it may be because of the variable used. See if this works:

[code moved to second post in topic]
« Last Edit: March 01, 2007, 08:26:57 AM by JPDeni »

soMzE

  • Guest
Re: [Reguest] Tag Cloud snippet
« Reply #15 on: March 01, 2007, 08:12:22 AM »
That works great!!  ;D Shall i update the first post with this new code JPDeni?

JPDeni

  • Guest
Re: [Reguest] Tag Cloud snippet
« Reply #16 on: March 01, 2007, 08:21:31 AM »
I'll update my posts with the correct code and clean things up a bit for future reference. I'm sure there will be others who will be interested in using this.

whatever

  • Guest
Re: [Reguest] Tag Cloud snippet
« Reply #17 on: March 05, 2007, 11:22:02 AM »
JPDeni:
The code generates a tag cloud just fine, thanks you  8)
A question, please - it is supposed to produce texts of varying size, because it does not do that for me?
Thanks

JPDeni

  • Guest
Re: [Reguest] Tag Cloud snippet
« Reply #18 on: March 05, 2007, 11:26:41 AM »
Yes, it is, if the members have different numbers of posts. If all of them listed have the same number of posts, then the text would all be the same size.

whatever

  • Guest
Re: [Reguest] Tag Cloud snippet
« Reply #19 on: March 05, 2007, 01:44:47 PM »
Then I have a problem, as the members listed have different numbers of posts, yet the font size remains the same.
I am using the code from the second post:
Code: [Select]
]global $db_prefix, $scripturl;
$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 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 = 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;