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: 629
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 466
  • Total: 466

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.

akulion

thanks JP - i just wanted to check with the expert before I end up sending the script into some recursive loop which could cause the page to go down

u never know lol i've done it once before with fopen urls :2funny:

elliel

#71
Quote from: JPDeni on August 04, 2006, 05:51:23 AM
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 only drawback is that if you have a prolific poster with a really long name, it might distort your blocks.

I am just trying this out now and there seems to be a lot of members with spaces in their names so it looks horrible with big  all over the cloud.

(I looked at your site and it looks really nice on there)

Anyway to get rid of it?

Also I don't show in the cloud, is that because I'm Admin?

And we only have 8 members showing up in the cloud, and two font sizes - small and huge - is that because we only have 8 members that have posted in the last x number of posts?

My blocks are only 160px wide, is there a way to make the largest font smaller so they dont run over the edge of the blocks?

Sorry, didnt realise I had so many questions


the code I'm using from this thread is:

global $db_prefix, $scripturl;
$count= array();
$poster_number = array();
$query = db_query(
    "SELECT realName, {$db_prefix}messages.ID_MEMBER, ID_GROUP
     FROM {$db_prefix}members
     JOIN {$db_prefix}messages
     ON {$db_prefix}members.ID_MEMBER = {$db_prefix}messages.ID_MEMBER
     WHERE ID_GROUP <> 1 AND ID_GROUP <> 2
     ORDER BY posterTime DESC
     LIMIT 100", __FILE__, __LINE__);

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

$random = array_rand($count, count($count));
echo '<div style="text-align: center">';
foreach ($random as $value)
{
  $fsize = $count[$value] + 7;
  if ($fsize > 20)
    $fsize = 20;
  elseif ($fsize < 8)
    $fsize = 8;
  $name = str_replace(" ",'ÂÃ,·',$value);
  echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $poster_number[$value] . '">
          <span style="font-size:' . $fsize . 'pt;">' . $name . '</span></a> ';
}
echo '</div>';





JPDeni

QuoteI am just trying this out now and there seems to be a lot of members with spaces in their names so it looks horrible with big  all over the cloud.
I'm not sure what the  is from. What I use is a Ã,· but you can use anything. You can use a non-breaking space if you want. I'll go see if I can find that  in the original code and get rid of it. It shouldn't exist at all.

QuoteAlso I don't show in the cloud, is that because I'm Admin?
That's how I set it up, yes. It's easy to change.

QuoteAnd we only have 8 members showing up in the cloud, and two font sizes - small and huge - is that because we only have 8 members that have posted in the last x number of posts?
Yes, probably. This is designed for a more active site. But you should be able to adjust the font sizes to make things look better.

QuoteMy blocks are only 160px wide, is there a way to make the largest font smaller so they dont run over the edge of the blocks?
Certainly. There are lots of ways to alter it.

Okay... to change things.

If you want admins and global moderators to show up in the cloud, delete the line


     WHERE ID_GROUP <> 1 AND ID_GROUP <> 2


If you want to get rid of that  thing (still don't know why that exists), change

  $name = str_replace(" ",'ÂÃ,·',$value);


to

  $name = str_replace(" ",'Ã,·',$value);


If you want to make the largest font smaller, play around with


  if ($fsize > 20)
    $fsize = 20;


Change the 20 -- in both places -- to whatever you want. That is the determiner of the largest font.

Similarly, if you should want to change the smallest font, play around with the 8 in


  elseif ($fsize < 8)
    $fsize = 8;


elliel

thanks, that works brilliantly :)

m771401

I really wanted to control that overflow thing...

This seems to have worked for me.

global $db_prefix, $scripturl;
$count= array();
$poster_number = array();
$query = db_query(
    "SELECT realName, {$db_prefix}messages.ID_MEMBER, ID_GROUP
     FROM {$db_prefix}members
     JOIN {$db_prefix}messages
     ON {$db_prefix}members.ID_MEMBER = {$db_prefix}messages.ID_MEMBER
     ORDER BY posterTime DESC
     LIMIT 100", __FILE__, __LINE__);

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

$random = array_rand($count, count($count));
echo '<div style="width: 160px; text-align: center; overflow: hidden;">';
foreach ($random as $value)
{
  $fsize = $count[$value] + 7;
  if ($fsize > 20)
    $fsize = 20;
  elseif ($fsize < 6)
    $fsize = 6;
  $name = str_replace(" ",' ',$value);
  echo '<a style="font-size:' . $fsize . 'pt;" class="normaltext" href="' . $scripturl . '?action=profile;u=' . $poster_number[$value] . '">' . $name . '</a> ';
}
echo '</div>';

JPDeni

You can delete the line


  $name = str_replace(" ",' ',$value);


The purpose of that line is to replace spaces with something so that the usernames won't break in the middle. The downside of it is that sometimes a long name will have a large font and it'll stretch the block, especially if your blocks are narrow.

m771401

Ah, That makes more sense now. I see why it is working for me then. However with the overflow set those long names will just clip instead of going outside the block. So it's a compromise. Which is fine by me. I kind of like the chaos of the cloud with the names split up though.

vdubbia

Quote from: m771401 on March 01, 2007, 03:24:23 PM
I really wanted to control that overflow thing...

This seems to have worked for me.

global $db_prefix, $scripturl;
$count= array();
$poster_number = array();
$query = db_query(
    "SELECT realName, {$db_prefix}messages.ID_MEMBER, ID_GROUP
     FROM {$db_prefix}members
     JOIN {$db_prefix}messages
     ON {$db_prefix}members.ID_MEMBER = {$db_prefix}messages.ID_MEMBER
     ORDER BY posterTime DESC
     LIMIT 100", __FILE__, __LINE__);

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

$random = array_rand($count, count($count));
echo '<div style="width: 160px; text-align: center; overflow: hidden;">';
foreach ($random as $value)
{
  $fsize = $count[$value] + 7;
  if ($fsize > 20)
    $fsize = 20;
  elseif ($fsize < 6)
    $fsize = 6;
  $name = str_replace(" ",' ',$value);
  echo '<a style="font-size:' . $fsize . 'pt;" class="normaltext" href="' . $scripturl . '?action=profile;u=' . $poster_number[$value] . '">' . $name . '</a> ';
}
echo '</div>';


how would I exclude Admins/Mods from the above code... tried adding WHERE ID_GROUP <> 1 AND ID_GROUP <> 2, but that crashed it.  Any ideas?

Awesome mod, btw... really a good motivator for users to get involved.

JPDeni

That's the code that you need to add. The only question is where you added it.


$query = db_query(
    "SELECT posterName, {$db_prefix}messages.ID_MEMBER, ID_GROUP
     FROM {$db_prefix}members
     JOIN {$db_prefix}messages
     ON {$db_prefix}members.ID_MEMBER = {$db_prefix}messages.ID_MEMBER
     WHERE ID_GROUP <> 1 AND ID_GROUP <> 2
     ORDER BY posterTime DESC
     LIMIT 100", __FILE__, __LINE__);


I know this works, because I copied the above from the block I have on my site.

Thanks for the nice words. I didn't expect that it would be that much of a motivator, but I've had several people say that they felt they had to post after they saw that they were off the cloud. People like to see their names.

m771401

Vdubbia, I just tested this and it works fine.


global $db_prefix, $scripturl;
$count= array();
$poster_number = array();
$query = db_query(
    "SELECT realName, {$db_prefix}messages.ID_MEMBER, ID_GROUP
     FROM {$db_prefix}members
     JOIN {$db_prefix}messages
     ON {$db_prefix}members.ID_MEMBER = {$db_prefix}messages.ID_MEMBER
     WHERE ID_GROUP <> 1 AND ID_GROUP <> 2
     ORDER BY posterTime DESC
     LIMIT 100", __FILE__, __LINE__);

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

$random = array_rand($count, count($count));
echo '<div style="width: 160px; text-align: center; overflow: hidden;">';
foreach ($random as $value)
{
  $fsize = $count[$value] + 7;
  if ($fsize > 20)
    $fsize = 20;
  elseif ($fsize < 6)
    $fsize = 6;
  $name = str_replace(" ",' ',$value);
  echo '<a style="font-size:' . $fsize . 'pt;" class="normaltext" href="' . $scripturl . '?action=profile;u=' . $poster_number[$value] . '">' . $name . '</a> ';
}
echo '</div>';


This website is proudly hosted on Crocweb Cloud Website Hosting.