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?

August 19, 2022, 05:24:08 AM

Login with username, password and session length
Members
  • Total Members: 3843
  • Latest: Tricky
Stats
  • Total Posts: 193479
  • Total Topics: 21088
  • Online today: 54
  • Online ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 1
Guests: 52
Total: 53

Author Topic: Poster cloud  (Read 33533 times)

0 Members and 1 Guest are viewing this topic.

JPDeni

  • Guest
Poster cloud
« on: August 03, 2006, 10:51:23 PM »
I thought it would be fun to have a "poster cloud" like the word cloud thing that people sometimes have on their blogs. I want to do a word cloud, too, but the posters were easier to start with.  ;)

Put the code below in a phpbox block. It will look at the 100 most recent posts on your forum and tally the number of posts within that 100 for each poster. It then prints out the posters' names in random order with the size of the font dependent on the number of posts for that poster. The fun thing is that the "cloud" will change from day to day or even hour to hour and it will encourage people to post so that they can see their names in the cloud.

I replaced spaces in names with a · character so that it wouldn't word-wrap in the middle of a username. The +7 is rather arbitrary, but it seemed to me that 8pt font (7 + 1 post) would be just about the smallest size that anyone could be expected to read.

The code:

Code: [Select]
global $db_prefix;
$count= array();

$query = db_query(
    "SELECT posterName
     FROM {$db_prefix}messages
     ORDER BY posterTime DESC
     LIMIT 100", __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($query))
{
  if (!isset($count[$row['posterName']]))
    $count[$row['posterName']] = 0;
  ++$count[$row['posterName']];
}

$random = array_rand($count, count($count));
echo '<div style="text-align: center">';
foreach ($random as $value)
{
  $fsize = $count[$value] + 7;
  $name = str_replace(" ",'·',$value);
  echo '<span style="font-size:' . $fsize . 'pt;">' . $name . '</span> ';
}
echo '</div>';

The only drawback is that if you have a prolific poster with a really long name, it might distort your blocks.
« Last Edit: February 24, 2007, 12:16:38 PM by JPDeni »

Xarcell

  • Guest
Re: Poster cloud
« Reply #1 on: August 03, 2006, 11:01:38 PM »
Dude! that's cool...

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Poster cloud
« Reply #2 on: August 03, 2006, 11:38:31 PM »
Very cool indeed! Thanks for sharing this!

akulion

  • Guest
Re: Poster cloud
« Reply #3 on: August 04, 2006, 06:12:58 AM »
this is really cool

:D thanks

im using it on my page if anyone wants a demo
« Last Edit: August 04, 2006, 06:18:59 AM by akulion »

Xarcell

  • Guest
Re: Poster cloud
« Reply #4 on: August 04, 2006, 06:25:10 AM »
@ Akulion

I didn't see teh demo. Also you have a parse error on your TOP POSTERS.

JPDeni

  • Guest
Re: Poster cloud
« Reply #5 on: August 04, 2006, 07:11:06 AM »
It's there. :-D I'm glad to see that someone is getting use of it. I can't really show a demo because this is a shadow of a long-established existing board and I don't want people to get confused if it comes up in a Google search. I used a side block to have a narrower output. It's a little more "cloud-like". But it did occur to me that I could take a screenshot of it. So here it is.

Xarcell

  • Guest
Re: Poster cloud
« Reply #6 on: August 04, 2006, 07:21:57 AM »
I may have to put that on my site.

akulion

  • Guest
Re: Poster cloud
« Reply #7 on: August 04, 2006, 07:39:14 AM »
oh sorry about that

i was JUST messing with it and i accidentally put an extra ' in the code

just fate that u happend to see it RIGHT then lol

ive fixed it now :D

sburke930

  • Guest
Re: Poster cloud
« Reply #8 on: August 19, 2006, 01:29:09 PM »
I would like to exclude the admin and moderators from this block.  How do I go about doing that?

JPDeni

  • Guest
Re: Poster cloud
« Reply #9 on: August 19, 2006, 01:38:42 PM »
Well.... :) That would be a little more involved. It would require a JOIN between the messages and the members tables and a WHERE statement to exclude certain groups. I'll cogitate on it a bit and see what I can come up with.