SimplePortal

Customization => Blocks and Modifications => Topic started by: Blue on April 29, 2009, 09:49:13 PM

Title: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Blue on April 29, 2009, 09:49:13 PM
[FOR SMF 2.0 ONLY]

Hi :)

I wanted a mod that could join all the TOP I used: Top Posts, Top Karmas and Top Money (SMF Shop)

So, I decided to do one. Here it is:

Updated: HTML Validity - Thanks to [SiNaN]

Without TOP Money (Use this if you don't have SMF Shop)
Code: [Select]
//TOP POSTS

   //TOP POSTS [TITLE]
   echo'
<div class="smalltext" style="text-align: center; color: #216095;">
   <img src="http://img527.imageshack.us/img527/3337/86263199.gif" alt="posts" />
   <strong>Top Posts</strong>
</div>
   <hr />';
   
   // TOP POSTS [CODE]
   global $boarddir, $memberContext;

   require_once($boarddir.'/SSI.php');

   $top_given = ssi_topPoster(3, 'array');

   echo '<table>';

   foreach ($top_given as $member)
   {
      loadMemberData($member['id']);
      loadMemberContext($member['id']);

      echo '
      <tr>
        <td style="width: 55px; text-align: center;">', !empty($memberContext[$member['id']]['avatar']['href']) ? '
          <img src="' . $memberContext[$member['id']]['avatar']['href'] . '" alt="' . $member['name'] . '" width="30" height="27" />' : '', '
        </td>
        <td>
          ', $member['link'], '<br />
          <span class="smalltext">
            <strong>Posts:</strong> ', $member['posts'], '
          </span>
        </td>
      </tr>';
   }
   echo '
   </table>';

echo'   
<br />';
   
//TOP KARMAS

   //TOP KARMAS [TITLE]
echo'
<div class="smalltext" style="text-align: center; color: #216095;">
   <img src="http://img2.imageshack.us/img2/419/85312373.gif" alt="karma" />
   <strong>Top Karmas</strong>
</div>
   <hr />';

   // TOP KARMAS [CODE]
global $smcFunc, $scripturl, $memberContext;

$members_result = $smcFunc['db_query']('', '
   SELECT id_member, real_name, karma_good
   FROM {db_prefix}members
   ORDER BY karma_good DESC
   LIMIT 3');
$members = array();
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
   $members[] = array(
      'name' => $row_members['real_name'],
      'id' => $row_members['id_member'],
      'karma' => $row_members['karma_good'],
      'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
      'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
   );
}
$smcFunc['db_free_result']($members_result);

if (empty($members))
   return;
   
echo '<table>';   

foreach ($members as $karma) {
   echo '
   <tr>
      <td style="width: 55px; text-align: center;">', !empty($memberContext[$karma['id']]['avatar']['href']) ? '
         <img src="' . $memberContext[$karma['id']]['avatar']['href'] . '" alt="' . $karma['name'] . '" width="30" height="27" />' : '', '
      </td>
      <td>
         ', $karma['link'], '<br />
          <span class="smalltext">
            <strong>Karmas:</strong> ', $karma['karma'], '
          </span>
      </td>
   </tr>';

echo '
</table>';

With TOP Money (only if you have SMF Shop)
Code: [Select]
//TOP POSTS

   //TOP POSTS [TITLE]
   echo'
<div class="smalltext" style="text-align: center; color: #216095;">
   <img src="http://img527.imageshack.us/img527/3337/86263199.gif" alt="posts" />
   <strong>Top Posts</strong>
</div>
   <hr />';
   
   // TOP POSTS [CODE]
   global $boarddir, $memberContext;

   require_once($boarddir.'/SSI.php');

   $top_given = ssi_topPoster(3, 'array');

   echo '<table>';

   foreach ($top_given as $member)
   {
      loadMemberData($member['id']);
      loadMemberContext($member['id']);

      echo '
      <tr>
        <td style="width: 55px; text-align: center;">', !empty($memberContext[$member['id']]['avatar']['href']) ? '
          <img src="' . $memberContext[$member['id']]['avatar']['href'] . '" alt="' . $member['name'] . '" width="30" height="27" />' : '', '
        </td>
        <td>
          ', $member['link'], '<br />
          <span class="smalltext">
            <strong>Posts:</strong> ', $member['posts'], '
          </span>
        </td>
      </tr>';
   }
   echo '
   </table>';

echo'   
<br />';
   
//TOP KARMAS

   //TOP KARMAS [TITLE]
echo'
<div class="smalltext" style="text-align: center; color: #216095;">
   <img src="http://img2.imageshack.us/img2/419/85312373.gif" alt="karma" />
   <strong>Top Karmas</strong>
</div>
   <hr />';

   // TOP KARMAS [CODE]
global $smcFunc, $scripturl, $memberContext;

$members_result = $smcFunc['db_query']('', '
   SELECT id_member, real_name, karma_good
   FROM {db_prefix}members
   ORDER BY karma_good DESC
   LIMIT 3');
$members = array();
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
   $members[] = array(
      'name' => $row_members['real_name'],
      'id' => $row_members['id_member'],
      'karma' => $row_members['karma_good'],
      'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
      'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
   );
}
$smcFunc['db_free_result']($members_result);

if (empty($members))
   return;
   
echo '<table>';   

foreach ($members as $karma) {
   echo '
   <tr>
      <td style="width: 55px; text-align: center;">', !empty($memberContext[$karma['id']]['avatar']['href']) ? '
         <img src="' . $memberContext[$karma['id']]['avatar']['href'] . '" alt="' . $karma['name'] . '" width="30" height="27" />' : '', '
      </td>
      <td>
         ', $karma['link'], '<br />
          <span class="smalltext">
            <strong>Karmas:</strong> ', $karma['karma'], '
          </span>
      </td>
   </tr>';

echo '
</table>';

   // TOP MONEY [CODE]
global $smcFunc, $scripturl, $memberContext;

$members_result = $smcFunc['db_query']('', '
   SELECT id_member, real_name, money
   FROM {db_prefix}members
   ORDER BY money DESC
   LIMIT 3');
$members = array();
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
   $members[] = array(
      'name' => $row_members['real_name'],
      'id' => $row_members['id_member'],
      'money' => $row_members['money'],
      'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
      'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
   );
}
$smcFunc['db_free_result']($members_result);

if (empty($members))
   return;

echo '<table>'; 
   
foreach ($members as $money) {
   echo '
   <tr>
      <td style="width: 55px; text-align: center;">', !empty($memberContext[$money['id']]['avatar']['href']) ? '
         <img src="' . $memberContext[$money['id']]['avatar']['href'] . '" alt="' . $money['name'] . '" width="30" height="27" />' : '', '
      </td>
      <td>
         ', $money['link'], '<br />
          <span class="smalltext">
            <strong>Money:</strong> ', $money['money'], '
          </span>
      </td>
   </tr>';
}
echo '
</table>';

ScreenShot Attached. Hope you like it ;)
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Nathaniel on April 30, 2009, 01:49:35 AM
Looks good. Moved to the Blocks and Modifications board. :)
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Blue on April 30, 2009, 04:28:45 AM
Thanks ;D
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: aceflybye on May 05, 2009, 01:04:52 AM
Thank you, awesome job did you get smf shop on 2.0 rc1
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: [SiNaN] on May 05, 2009, 05:16:27 AM
Good job Blue! Looks great.

Here are some suggestions to make it perfect.

For this code:

Code: [Select]
<center><img src="http://img259.imageshack.us/img259/7306/yen.png" align="abscenter" > <span class="smalltext"><font color="#216095"><b>Top Money</b></font></span></center>
I'd have used this:

Code: [Select]
<div class="smalltext" style="text-align: center; color: #216095;">
<img src="http://img259.imageshack.us/img259/7306/yen.png" alt="money" />
<strong>Top Money</strong>
</div>

So you put everything in a div which has smalltext class assigned and text inside is aligned to center by text-align: center; and text color is set with color: #216095;.

With this, you can get rid of deprecated tags (center and font) and an extra span tag. In addition, you won't need to use align attribute for img tag, which is also decprecated, as text-align: center; for the div would align it to center too. Also, instead of deprecated tag, b, you can use strong. Lastly, img tag requires alt attribute to be HTML valid.

Also, instead of <hr> use <hr /> and for <br/ > or <br> use <br />, again for HTML validity.
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Blue on May 05, 2009, 07:11:16 AM
 :0 Didn't knew about HTML validity

I'm going to change that, then :) -----> Done ;)

Thanks for the "teaching lessons" ;D I'm learning, I'm learning :D

The <div> thing is cool. At least the code becomes more eye looking :P
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: [SiNaN] on May 05, 2009, 07:26:11 AM
Looks great, well done! You're learning fast. :D
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Blue on May 05, 2009, 07:31:22 AM
I'm a quick learner, I told you on the other topic eheh :P

Any problem if my next block be a "Shoutbox Smart Block" (with detection of the shoutbox installed?) :-[
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: [SiNaN] on May 05, 2009, 07:32:39 AM
Of course not, you can code whatever you like. ;)

Also, while creating "smart blocks" you can cheat from built-in "intelligent blocks" of SimplePortal. ;P
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Blue on May 05, 2009, 07:40:56 AM
Also, while creating "smart blocks" you can cheat from built-in "intelligent blocks" of SimplePortal. ;P

I know, I know, I was already doing that eheh :P
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: MUSTAFAINE on May 07, 2009, 04:43:02 AM
why it isnt worked at mine site are we include the codes in php area
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Blue on May 07, 2009, 07:23:34 AM
Hello MUSTAFAINE,

It isn't working because you are using SMF 1.1.8 and this is ONLY for SMF 2.0 ;)
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: MUSTAFAINE on May 07, 2009, 10:32:09 AM
you right blue, i just want to ask the all mods for 2.0 or not.

i couldn`t see any comment but i am new here I ll learn the site thanks..
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Blue on May 07, 2009, 11:00:58 PM
The blocks made by me are for SMF 2.0

I've updated them with a warning telling it's only for SMF 2 ;)
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: CrossFaith on June 22, 2009, 09:08:40 PM
Blue can you code one for 1.1.9 please ^^
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: primetime on July 10, 2009, 08:36:58 PM
If I wanted to exclude certain groups, how would I code that in?

Thank you,
Prime
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Blue on July 10, 2009, 09:04:39 PM
It would require some
Blue can you code one for 1.1.9 please ^^

Sorry, it's only available for SMF 2.0

If I wanted to exclude certain groups, how would I code that in?

Thank you,
Prime

The only solution I know is that would require to call the table of the members of the database and then put the code in an IF.
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Oskarlover on April 16, 2010, 02:58:10 AM
Any way to make it show the user colors?

Like the Admin: Red
Mods: Green
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Pervert on October 30, 2010, 11:24:29 AM
Can anyone add the code for Top Arcade Players as well?
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: shuban on January 31, 2011, 11:34:03 AM
Can someone please help me adapt the highest karma code to 1.1.12?

Code: [Select]
// TOP KARMAS [CODE]
global $smcFunc, $scripturl, $memberContext;

$members_result = $smcFunc['db_query']('', '
   SELECT id_member, real_name, karma_good
   FROM {db_prefix}members
   ORDER BY karma_good DESC
   LIMIT 3');
$members = array();
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
   $members[] = array(
      'name' => $row_members['real_name'],
      'id' => $row_members['id_member'],
      'karma' => $row_members['karma_good'],
      'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
      'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
   );
}
$smcFunc['db_free_result']($members_result);

if (empty($members))
   return;

foreach ($members as $karma)
   echo '
   <table>
   <tr>
      <td style="width: 55px; text-align: center;">', !empty($memberContext[$karma['id']]['avatar']['href']) ? '
         <img src="' . $memberContext[$karma['id']]['avatar']['href'] . '" alt="' . $karma['name'] . '" width="30" height="27" />' : '', '
      </td>
      <td>
         ', $karma['link'], '<br />
          <span class="smalltext">
            <strong>Karmas:</strong> ', $karma['karma'], '
          </span>
      </td>
   </tr>';
   
echo '
</table>';

I wanted to adapt it into the SSI.php file and give it a ssi_NAME. Here's what I did:

Code: [Select]
// TOP KARMAS [CODE]

function ssi_topKARMA($topNumber = 1, $num_posts, $output_method

= 'echo')
{

global $smcFunc, $scripturl, $memberContext;

$members_result = $smcFunc['db_query']('', '
   SELECT id_member, real_name, karma_good
   FROM {db_prefix}members
   ORDER BY karma_good DESC
   LIMIT 3');
$members = array();
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
   $members[] = array(
      'name' => $row_members['real_name'],
      'id' => $row_members['id_member'],
      'karma' => $row_members['karma_good'],
      'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
      'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
   );
}
$smcFunc['db_free_result']($members_result);

if (empty($members))
   return;

foreach ($members as $karma)
   echo '
   <table>
   <tr>
      <td style="width: 55px; text-align: center;">', !empty($memberContext[$karma['id']]['avatar']['href']) ? '
         <img src="' . $memberContext[$karma['id']]['avatar']['href'] . '" alt="' . $karma['name'] . '" width="30" height="27" />' : '', '
      </td>
      <td>
         ', $karma['link'], '<br />
          <span class="smalltext">
            <strong>Karmas:</strong> ', $karma['karma'], '
          </span>
      </td>
   </tr>';
   
echo '
</table>';

}

When I call the SSI function in index, it gives me some kind of "string" error. Can anyone tell me what I may be doing wrong? Normally, calling SSI functions in the index.template.php works perfectly. By the way, I do not have simple portals installed.

Website: http://biology-forums.com

Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: donidion on April 08, 2011, 06:36:26 AM
Looks good. Moved to the Blocks and Modifications board. :)

you are master
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Tricky on February 13, 2012, 03:22:10 PM
Can someone update this please

Thanks

 :D
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Kryzen on February 13, 2012, 03:25:12 PM
This should work without any problem on SMF 2.0.2 :)
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Tricky on February 13, 2012, 03:39:34 PM
Yes it does i'm sorry delete post i was putting the code in html duh

Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: NeoxII on August 19, 2012, 09:04:40 PM
Hi  :)
With smf 2.0.2 Top Karmas avatars disappear but top poster avatars works perfectly, can you help me?

Thank you very much!  :thumbsup:
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: NeoxII on August 21, 2012, 05:56:29 AM
Can you help me?  :nervous-happy:
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: NeoxII on August 22, 2012, 08:10:28 PM
excuse me for bump but I need help with this code....
Thank you

 ;)
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: Old Fossil on August 22, 2012, 08:19:04 PM
It does help if you state what the help you require is.

 :nervous-happy:
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: NeoxII on August 22, 2012, 09:08:05 PM
Hi  :)
With smf 2.0.2 Top Karmas avatars disappear but top poster avatars works perfectly, can you help me?

Thank you very much!  :thumbsup:

 :)
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: kachan64 on September 07, 2012, 11:01:47 AM
 :in-love: Code Looks great.

I've modified the code a bit for other mod I have instead of karma.


For anyone who are interested to do so, you'll need knowledge on phpmyadmin, smf and a bit of php.


Preview:
Sorry, I've enabled this for members only. Please join here (http://chatngo.us.tc") before you can preview it.
I've renamed from karma to likes, since that what I use.
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: unci on September 30, 2013, 02:13:23 PM
:in-love: Code Looks great.

I've modified the code a bit for other mod I have instead of karma.

For anyone who are interested to do so, you'll need knowledge on phpmyadmin, smf and a bit of php.

  • Well, first login to your host.
  • Open phpMyAdmin
  • Find your SMF database.
  • Search for "smf_members" without the quotes.
  • By looking at the columns, other mod will also store a new filed. (example: "smf like" mod etc)
  • Copy the name of the column. (example: installed_mod)
  • Change the following to installed_mod for example:
  •   SELECT id_member, real_name, installed_mod
       FROM {db_prefix}members
       ORDER BY installed_mod DESC

  • This will select installed_mod from the table called "members" then sort nstalled_mod from lowest value to the highest.
  • This is it! You don't have to modify any other code, just hit save and you're done with a new rating system.

Preview:
Sorry, I've enabled this for members only. Please join here (http://chatngo.us.tc") before you can preview it.
I've renamed from karma to likes, since that what I use.

Hello,

I am not understanding point 8. What do you mean "SELECT id_member, real_name, installed_mod
   FROM {db_prefix}members, ORDER BY installed_mod DESC"? Thank you, please either respond here (http://www.seocompanylosangeles.biz) or pm me.
Title: Re: TOP - Posts, Karmas and Money (SMF Shop)
Post by: thomsalva on October 12, 2013, 11:50:27 AM
Hmmm... is it possible to insert default membergroup color instead of been the same color for all names...
SimplePortal 2.3.8 © 2008-2024, SimplePortal