SimplePortal

Customization => Custom Coding => Topic started by: rlake on May 12, 2013, 02:30:27 PM

Title: Top x Posters (BLOCK)
Post by: rlake on May 12, 2013, 02:30:27 PM
I have some blocks I made for a different kind of board and portal system for a freind. I am working on porting them so to SMF and SimplePoral. I just wrote this block while I was trying to get the hang of making blocks for Simple Portal. There is a setting to change the title text color and I setting to change the amount of posters to display.

This works for smf 2.04. I am not sure if it will work with any other versions.


(http://i39.tinypic.com/of0yyp.jpg)

Code: [Select]
<?php
global $smcFunc$scripturl;

// Configurable settings
$limit 10;                // Amount of posters to display
$tcolor "006633";   // Color of title text

   
echo'<table width="100%" border="1">
<tr><td width="70%"><center><b><font color="'
.$tcolor.'">Poster Name</font></b></center></td>
<td width="30%"><center><b><font color="'
.$tcolor.'">Post</span></b></font></td>
</tr>'
;

$pcresult $smcFunc['db_query'](''"
 SELECT id_member, member_name, posts, id_group, id_post_group
 FROM {db_prefix}members
 ORDER BY posts DESC
 LIMIT 
$limit");  
while ($pcount $smcFunc['db_fetch_assoc']($pcresult))
{
$poster=$pcount['member_name'];
$count=$pcount['posts'];
$memid=$pcount['id_member'];

if ($pcount['id_group'] == 0)
{
    $group=$pcount['id_post_group'];
}
else
{
   $group=$pcount['id_group'];
}

//Adding Color
$clresult $smcFunc['db_query']('''
   SELECT id_group, online_color
   FROM {db_prefix}membergroups'
);
   while ($cl $smcFunc['db_fetch_assoc']($clresult))
{

if ($cl['id_group'] == $group)
{
   $color=$cl["online_color"];
}
}

   echo'<tr>
<td><a href="'
$scripturl'?action=profile;u='$memid' "><font color="'.$color.'"><u>'.$poster.'</u></font></a></td>
<td><center>'
.$count.'</center></td>
</tr>'
;
}

   echo
'</table>';

$smcFunc['db_free_result']($dbresult);


?>
Title: Re: Top x Posters (BLOCK)
Post by: Old Fossil on May 12, 2013, 03:30:09 PM
Did you know there is already a Top Poster block.

It's a good start though.

 :nervous-happy:
Title: Re: Top x Posters (BLOCK)
Post by: rlake on May 12, 2013, 04:31:14 PM
Yea I know. This one was just a learning experience and a chance to try to learn how smf has their database structured.
Title: Re: Top x Posters (BLOCK)
Post by: Old Fossil on May 12, 2013, 04:33:21 PM
Using a block which is already available as a guide is a good idea.

Ya more braver tyhan I am for sure.

 :D
SimplePortal 2.3.8 © 2008-2024, SimplePortal