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

Recent

Welcome to TinyPortal. Please login or sign up.

April 18, 2024, 05:37:48 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,164
  • Total Topics: 21,219
  • Online today: 203
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 167
  • Total: 167

Poster cloud

Started by JPDeni, August 04, 2006, 05:51:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JPDeni

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:

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.

Xarcell


IchBin

Very cool indeed! Thanks for sharing this!

akulion

#3
this is really cool

:D thanks

im using it on my page if anyone wants a demo

Xarcell

@ Akulion

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

JPDeni

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

I may have to put that on my site.

akulion

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

I would like to exclude the admin and moderators from this block.  How do I go about doing that?

JPDeni

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.