SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: Stigmartyr on January 21, 2010, 01:57:11 AM

Title: 3 in 1 member stats block
Post by: Stigmartyr on January 21, 2010, 01:57:11 AM
Hey folks, it's me again with another block request for member stats.  The good news is that I have the code handy, but the bad news is that it's for SMF 1.1.x

All we'd need is someone handy who knows how to convert the database calls in the PHP script and we'd have us a pretty neat block!

See attached.  Here's a demo of what it would look like: www.StangNation.com (scroll to the bottom for "Recent Members / Top Posters / Weekly Top Posters"

Title: Re: 3 in 1 member stats block
Post by: Stigmartyr on January 24, 2010, 12:40:52 AM
 :in-love:  I am liking to be having this mod.  Ty!
Title: Re: 3 in 1 member stats block
Post by: Stigmartyr on January 27, 2010, 03:37:00 PM
:in-love:  I am liking to be having this mod.  Ty!


Pretty please! :)
Title: Re: 3 in 1 member stats block
Post by: ccbtimewiz on January 27, 2010, 06:41:09 PM
Here it is for SMF 2.0. I simply converted it-- personally I don't like the HTML.

Code: [Select]
global $smcFunc, $memberContext;

$count = 3;
$users = array();

$request = $smcFunc['db_query']('', '
SELECT id_member
FROM {db_prefix}members
WHERE is_activated = 1
ORDER BY id_member DESC
LIMIT {int:limit}',
array(
'limit' => $count,
)
);

while ($row = $smcFunc['db_fetch_assoc']($request))
$users[] = intval($row['id_member']);

loadMemberData($users);

echo'<table border="0" width="100%" id="table1" cellpadding="2" style="border-collapse: collapse">
<tr><td  bgcolor="#990000" width="150" align="center"><font color="#FFFFFF" face="Verdana" size="2"><b>New Bloods</b></font></td><td bgcolor="#cc0000" width="200" align="center"><font color="#FFFFFF" face="Verdana" size="2"><b>Top 15 Posters</b></font></td><td  bgcolor="#990000" align="center"><font color="#FFFFFF" face="Verdana" size="2"><b>This Weeks Top Posters</b></font></td></tr><tr>
<td align="center">';
$i = 0;
foreach($users as $user_id)
{
if ($i > 0)
echo '<hr />';

$i++;

loadMemberContext($user_id);

if (!empty($memberContext[$user_id]['avatar']['image']))
echo '<div align="center">'.$memberContext[$user_id]['avatar']['image'] . '<br />' . $memberContext[$user_id]['link'].'</div>';
else
echo '<div align="center"><img src="http://yourwebsite/default_avatar.gif" height="80" widh="80"><br /><br />'.$memberContext[$user_id]['link'].'</div>';
}

$numberofposters = 15; // You can change this to however many you want

require_once('SSI.php');
$top_posters = ssi_topPoster($numberofposters, 'return');
echo'</td><td align="center">';
foreach ($top_posters as $poster)
{
  echo $poster['link'] , ' (', $poster['posts'] , ')<br />';
}
echo'</td><td>';

$count = array();

$query = $smcFunc['db_query']('', '
SELECT poster_name
FROM {db_prefix}messages
ORDER BY poster_time DESC
LIMIT 100', array()
);

while ($row = $smcFunc['db_fetch_assoc']($query))
{
if (!isset($count[$row['poster_name']]))
$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></td></tr>
</table>';
Title: Re: 3 in 1 member stats block
Post by: Stigmartyr on January 27, 2010, 07:15:11 PM
Not a big fan of the html either but I can probably try to tweak it somewhat.  Thanks for taking the time to look at this.

BTW - I noticed the third column which usually shows a name cloud of top weekly posters, isn't showing anything.  Maybe something missed in the function?
Title: Re: 3 in 1 member stats block
Post by: ccbtimewiz on January 27, 2010, 07:37:28 PM
I didn't see anything wrong with it when I converted it-- there is a chance that the SSI function is not working. Perhaps change:

Code: [Select]
$top_posters = ssi_topPoster($numberofposters, 'return');
To:

Code: [Select]
$top_posters = ssi_topPoster($numberofposters, 'array');
Title: Re: 3 in 1 member stats block
Post by: Stigmartyr on January 27, 2010, 09:41:03 PM
I didn't see anything wrong with it when I converted it-- there is a chance that the SSI function is not working. Perhaps change:

Code: [Select]
$top_posters = ssi_topPoster($numberofposters, 'return');
To:

Code: [Select]
$top_posters = ssi_topPoster($numberofposters, 'array');

Hrmmm - tried it both ways, it's being stubborn..  but thank you for helping me with this! :)
SimplePortal 2.3.8 © 2008-2024, SimplePortal