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

Recent

Welcome to TinyPortal. Please login or sign up.

May 17, 2024, 09:30:39 AM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 59
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 30
  • Total: 30

Top Stats - 3 in 1 Block

Started by akulion, November 04, 2006, 03:53:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wilsy

I've been playing again with this block, it's excellent! I now have: -

Latest Boys, Top 20 Posters, Latest Girls, Latest Posts, Forum Categories/Boards/Search

Demo at www.rewindlancs.com in frontpage block (guests can view).

global $db_prefix, $memberContext, $modSettings, $scripturl;


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


$request = db_query("
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 AND gender = 1 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);

while ($row = mysql_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="#eae9e9" width="20%"><font color="#16b7c5" face="Verdana" size="2"><b>Latest Boys</b></font></td><td bgcolor="#eae9e9" width="20%"><font color="#16b7c5" face="Verdana" size="2"><b>Top 20</b></font></td><td  bgcolor="#eae9e9" width="20%"><font color="#16b7c5" face="Verdana" size="2"><b>Latest Girls</b></font></td><td  bgcolor="#eae9e9" width="20%"><font color="#16b7c5" face="Verdana" size="2"><b>Latest Posts</b></font></td><td bgcolor="#eae9e9" width="20%"><font color="#16b7c5" face="Verdana" size="2"><b>Community</b></font></td></tr><tr>
<td>';
$i = 0;
foreach($users as $user_id) {
if ($i > 0) echo '';
$i++;

loadMemberContext($user_id);

if (!empty($memberContext[$user_id]))
echo '<div align="left"><img src="http://rewindlancs.com/forum/Themes/OverViewLight_tp/images/Male.gif"/> '.$memberContext[$user_id]['link'].'</div>';
}

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

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

global $db_prefix, $memberContext, $modSettings, $scripturl;


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


$request = db_query("
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 AND gender = 2 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($request)) {
$users[] = intval($row['ID_MEMBER']);
}

loadMemberData($users);
$i = 0;
foreach($users as $user_id) {
if ($i > 0) echo '';
$i++;

loadMemberContext($user_id);

if (!empty($memberContext[$user_id]))
echo '<div align="left"><img src="http://rewindlancs.com/forum/Themes/OverViewLight_tp/images/Female.gif"/> '.$memberContext[$user_id]['link'].'</div>';
}

echo '</div></td><td>';


    // is it a number?
//if(!is_numeric($context['TPortal']['recentboxnum']))
$context['TPortal']['recentboxnum']='20';

// leave out the recycle board, if any
if(isset($modSettings['recycle_board']))
$bb=array($modSettings['recycle_board']);
else
$bb=array();

$what=ssi_recentTopics($num_recent = $context['TPortal']['recentboxnum'], $bb, $output_method = 'array');
// Output the topics
$counter=1; $cmax=count($what);
foreach($what as $w){
echo '
<a href="'.$w['href'].'">'.shorten_subject($w['short_subject'], 10).'</a><br>
';
$counter++;
}

echo'</td><td>';

global $db_prefix, $context, $user_info, $scripturl;

if (!isset($context['jump_to']))
{
// Find the boards/cateogories they can see.
$request = db_query("
SELECT c.name AS catName, c.ID_CAT, b.ID_BOARD, b.name AS boardName, b.childLevel
FROM {$db_prefix}boards AS b
LEFT JOIN {$db_prefix}categories AS c ON (c.ID_CAT = b.ID_CAT)
WHERE $user_info[query_see_board]", __FILE__, __LINE__);
$context['jump_to'] = array();
$this_cat = array('id' => -1);
while ($row = mysql_fetch_assoc($request))
{
if ($this_cat['id'] != $row['ID_CAT'])
{
$this_cat = &$context['jump_to'][];
$this_cat['id'] = $row['ID_CAT'];
$this_cat['name'] = $row['catName'];
$this_cat['boards'] = array();
}

$this_cat['boards'][] = array(
'id' => $row['ID_BOARD'],
'name' => $row['boardName'],
'child_level' => $row['childLevel'],
'is_current' => isset($context['current_board']) && $row['ID_BOARD'] == $context['current_board']
);
}
mysql_free_result($request);
}

foreach ($context['jump_to'] as $category)
{
echo '<span class="smalltext" style="text-decoration: underline; font-weight: bold;">', $category['name'], '<br /></span>';
foreach ($category['boards'] as $board)
echo '<span class="smalltext"><a href="' . $scripturl . '?board=' . $board['id'] . '.0">'. str_repeat('..', $board['child_level'] + 1) . $board['name'] . '</a><br /></span>';
}
TPortal_searchbox();
echo '</td></tr>
</table>';


NOTE: You will need to replace these two lines with the url of your male/female icons: -

<img src="http://rewindlancs.com/forum/Themes/OverViewLight_tp/images/Female.gif"/>

<img src="http://rewindlancs.com/forum/Themes/OverViewLight_tp/images/Male.gif"/>

Regards,

Wilsy.

Lord Anubis


rockyrails

Very cool variation - works really well with your site.
cheers Ferd   :up:

alhaudhie

how can i make it to put in top 10 poster only the user have posting under 100?

jepot

how to put an underline on each heading of the table?

jdvarner

i would like to just get the top posters for the day? anyone got code for that? thanks.

stigmartyr

What would I have to change to get this to work with SMF2?  I've tried digging around in SSI.php and only got myself into trouble.

Many thanks in advance.

IchBin

TP for SMF2 isn't even out, what do you need this for?

You'll have to convert all the database calls in the code to the SMF2 functions. That's why it won't work.

stigmartyr

Quote from: IchBinâ„¢ on January 21, 2010, 05:36:19 AM
TP for SMF2 isn't even out, what do you need this for?

You'll have to convert all the database calls in the code to the SMF2 functions. That's why it won't work.

Hi Ich - that's what I was having trouble with I don't know exactly what needs to be changed where.  I started poking around in the SSI.php of my SMF 2 instance.  I have a sandbox up and I wanted to try to get that working.  There's the 3 functions it does but I couldn't seem to figure it out :(

JPDeni

The code for the stats is designed to be in a TinyPortal block. You can't have a TinyPortal block at the moment if you are running SMF 2.0. Therefore, you can't use the code for the stats with SMF 2.0. Once TinyPortal is available for SMF 2.0, we will be upgrading the code for all blocks, as needed.