TinyPortal

Development => Block Codes => Topic started by: Xarcell on October 25, 2005, 03:48:23 AM

Title: Karma Leaders Block
Post by: Xarcell on October 25, 2005, 03:48:23 AM
Sorry for not adding all these ideas in one topic, they come to me at different times.

Again, this may already be a feature, I dunno, I'm not a tester.

How about a Karma Leaders block. Show 5-10 top users with the most karma.
Title: Re: Karma Leaders Block
Post by: bloc on October 25, 2005, 10:56:35 AM
That can be done I think..anyone else want this?
Title: Re: Karma Leaders Block
Post by: Nokonium on October 25, 2005, 01:47:11 PM
There was an SMF 1.0.5 Tip and Trick, that I use on Our-Local that added code to (iirc) who, that added highest and lowest Karma stats to the stats page, I haven't seen it for 1.1. To have highest or lowest displaying in a block would be a neat addition.
Title: Re: Karma Leaders Block
Post by: ontap on October 25, 2005, 04:39:52 PM

id be intrested.
Title: Re: Karma Leaders Block
Post by: Moocat on October 25, 2005, 09:26:55 PM
maybe also for users of the smf shop mod, a top 10 cash and top 10 banked cash members like they have when you hit the shop button? i'm not sure if the smf shop mod works well or at all with tp, or if its even compatible with rc1 :)

someone should remake it lol only this time let admins choose whats for sale! :)
Title: Re: Karma Leaders Block
Post by: resurgence on October 25, 2005, 09:35:00 PM
the shop mod need to be redone drastically to at least make it feel like the IPB one. installing the shop doesn't feel like it's worth it, especially if those are the only items on sale.

and also, it doesn't work with rc1.

and then it can be combioned with the vbuletting badge system ( i wish i had that one)
Title: Re: Karma Leaders Block
Post by: Xarcell on October 26, 2005, 12:54:12 AM
shop mod does need an overhaul.
Title: Re: Karma Leaders Block
Post by: Moocat on October 26, 2005, 02:33:18 AM
badge system?
Title: Re: Karma Leaders Block
Post by: resurgence on November 05, 2005, 05:54:23 AM
Quote from: Moocat on October 26, 2005, 02:33:18 AM
badge system?

yeah they badges underneath their avatar. and stuff.
Title: Re: Karma Leaders Block
Post by: Nokonium on January 02, 2006, 11:27:37 AM
Any progress on a Karma block?
Title: Re: Karma Leaders Block
Post by: bloc on January 02, 2006, 07:10:13 PM
duh..I totally forgot about this. I will see if I can put something together.
Title: Re: Karma Leaders Block
Post by: Nokonium on January 02, 2006, 07:14:52 PM
Thanks Bloc
Title: Re: Karma Leaders Block
Post by: ontap on January 02, 2006, 07:28:45 PM
dunno if this helps... i have it in "Statistics Center"
if your intrested heres how...

Open:
Themes\Default\Stats.template.php

Find:
echo'</tr></td><tr><td class="catbg" colspan="4"><b>', $txt['smf_stats_5'], '</b></td>

Before Add:

if( $modSettings['karmaMode'] == 1 )
{
echo '<tr>
<td class="catbg" colspan="2">Highest Karma Total</td>
<td class="catbg" colspan="2">Lowest Karma Total</td>
</tr>
<tr>
<td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';

foreach($context['htkarma'] as $htkarma)
{
$total = $htkarma['Good'] - $htkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$htkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}

echo'</td><td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';


foreach($context['ltkarma'] as $ltkarma)
{
$total = $ltkarma['Good'] - $ltkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$ltkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}
}

if( $modSettings['karmaMode'] == 2)
{
echo '<tr>
<td class="catbg" colspan="2">Highest Karma Rating</td>
<td class="catbg" colspan="2">Lowest Karma Rating</td>
</tr>
<tr>
<td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';

foreach($context['gkarma'] as $gkarma)
{
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$gkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">+'.$gkarma['Karma'].'</td>
</tr></table>';
}

echo'</td><td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';

foreach($context['bkarma'] as $bkarma)
{
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr valign="top"><td class="windowbg2" width="80%" align="left">'.
$bkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">-'.$bkarma['Karma'].'</td>
</tr></table>';
}
}


Works with SMF 1.0.5 not sure about SMF 1.1

.. a block with maybe the top 5 highest or lowest karma would be great,
ill try and do one if i can...
Title: Re: Karma Leaders Block
Post by: Nokonium on January 02, 2006, 08:51:25 PM
Thanks for the try Ontap, I've got that as well in 1.0.5 but it doesn't work in 1.1RC2. If I just paste it straight into a php block I get

Parse error: parse error, unexpected T_STRING in /homepages/########/htdocs/Fiddlers-Elbow/Sources/Load.php(1606) : eval()'d code(32) : eval()'d code on line 78

G_STRING's I know about, but T_STRING's  :-\
Title: Re: Karma Leaders Block
Post by: Mitch on March 15, 2006, 02:56:22 AM
Let me know if anything comes of this I am interested.
Title: Re: Karma Leaders Block
Post by: Nokonium on March 15, 2006, 12:25:38 PM
You can change any block name to whatever you want in the block admin. Within SMF you can call the Karma whatever you want. We use Bogle Points and the admins 'award' them for acts of stupidity.
Title: Re: Karma Leaders Block
Post by: Mitch on March 15, 2006, 12:53:41 PM
I am thinking what he meant was when you call up the function that it wont say something like:

Top Five Karma Leaders:
Bloc
>>Crip<<
IchBintm
borgBob
GerryMo

I am pretty sure Twin knows that he knows he can change the title of the block.

Or I could be totally wrong.
Title: Re: Karma Leaders Block
Post by: crip on March 15, 2006, 12:57:20 PM
Quote from: nokonium on March 15, 2006, 12:25:38 PM
You can change any block name to whatever you want in the block admin. Within SMF you can call the Karma whatever you want. We use Bogle Points and the admins 'award' them for acts of stupidity.

Lmao ;D
Title: Re: Karma Leaders Block
Post by: Nokonium on March 15, 2006, 02:35:23 PM
Quote from: Mitch on March 15, 2006, 12:53:41 PM
I am thinking what he meant was when you call up the function that it wont say something like:

Top Five Karma Leaders:
Bloc
>>Crip<<
IchBintm
borgBob
GerryMo

I am pretty sure Twin knows that he knows he can change the title of the block.

Or I could be totally wrong.
I would doubt if that would be hard coded, if it is you change it in the file, more likely to be "Top Five ['karma'] Leaders:" or similar. As what you call it is already defined in SMF, I'd expect someone creating a Karma block to use it.
Title: Re: Karma Leaders Block
Post by: Nokonium on March 15, 2006, 02:36:42 PM
Quote from: ÂÃ,»cripÂÃ,« on March 15, 2006, 12:57:20 PM
Lmao ;D
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.nokonium.plus.com%2FDr_Fuss-Bogle%2FYou%2520have%2520been%2Fbp-asking.gif&hash=894812982a754103966b78e1d3dd98a5960c7d4c)
Title: Re: Karma Leaders Block
Post by: Nokonium on March 21, 2006, 04:00:42 PM
I've been fiddling for the last couple of hours trying to do a Karma Totals block based on the SMF code from Tau Online and now I'm stuck.

I have this added to Stats.php
// Top 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);

$context['karma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
}

// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);

$context['bkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
}

// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);

$context['htkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}

// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);

$context['ltkarma'] = array();

while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}


And when this is added to Stats.template.php
if( $modSettings['karmaMode'] == 1 )
{
echo '<tr>
<td class="catbg" colspan="2">Well Bogled</td>
<td class="catbg" colspan="2">Goody Two Shoes</td>
</tr>
<tr>
<td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';

foreach($context['htkarma'] as $htkarma)
{
$total = $htkarma['Good'] - $htkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$htkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}

echo'</td><td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';


foreach($context['ltkarma'] as $ltkarma)
{
$total = $ltkarma['Good'] - $ltkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$ltkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}
}

if( $modSettings['karmaMode'] == 2)
{
echo '<tr>
<td class="catbg" colspan="2">Highest Karma Rating</td>
<td class="catbg" colspan="2">Lowest Karma Rating</td>
</tr>
<tr>
<td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';

foreach($context['gkarma'] as $gkarma)
{
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$gkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">+'.$gkarma['Karma'].'</td>
</tr></table>';
}

echo'</td><td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';

foreach($context['bkarma'] as $bkarma)
{
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr valign="top"><td class="windowbg2" width="80%" align="left">'.
$bkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">-'.$bkarma['Karma'].'</td>
</tr></table>';
}
}

echo'</tr></td><tr><td class="catbg" colspan="4"><b>', $txt['smf_stats_5'], '</b></td>
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  </tr>
<tr>
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  <td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_history.gif" border="0" width="20" height="20" alt="" /></td>
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  <td class="windowbg2" colspan="4">';


It works on SMF 1.1RC2 with TP 0.86b installed.

So having already got code added to Stats.php I set about adapting the code for a block. I've trimmed it down to just Karma Totals (I think) and stopped it messing up the other blocks, but I can't get the totals to display.

echo '<div style="padding: 5px;" class="smalltext">';

global $context, $settings, $options, $scripturl, $txt, $modSettings;

if( $modSettings['karmaMode'] == 1 )
{
'<table><tr><td class="windowbg2"Ã,  width="80%" align="left">';

foreach($context['htkarma'] as $htkarma)
{
$total = $htkarma['Good'] - $htkarma['Bad'];'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}
}
echo '</div>';


I think I may need to 'require Stats.php' but when I try to I get a fatal error. Would adding Tau Online's code to TPortal.php work and if so where should it be put?
Title: Re: Karma Leaders Block
Post by: IchBin on March 21, 2006, 07:17:33 PM
Where's your echo's?

echo '<div style="padding: 5px;" class="smalltext">';

global $context, $settings, $options, $scripturl, $txt, $modSettings;

if( $modSettings['karmaMode'] == 1 )
{
echo '<table><tr><td class="windowbg2" width="80%" align="left">';

foreach($context['htkarma'] as $htkarma)
{
$total = $htkarma['Good'] - $htkarma['Bad'];
echo '</td><td class="windowbg2" width="20%" align="right">'.$total.'</td></tr></table>';
}
}
echo '</div>';
Title: Re: Karma Leaders Block
Post by: Nokonium on March 21, 2006, 07:24:45 PM
Quote from: IchBinâ„¢ on March 21, 2006, 07:17:33 PM
Where's your echo's?

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.nokonium.plus.com%2Fblack-cat%2Fsurprised%2Fconfused4.gif&hash=fc7d9c07085e67ae8df886a5b44c1e6898354065)
Title: Re: Karma Leaders Block
Post by: G6Cad on March 21, 2006, 07:26:54 PM
I think IchBin alterd the code and put in some echos ;)
Seems like it in his post :D
Title: Re: Karma Leaders Block
Post by: IchBin on March 21, 2006, 07:27:39 PM
Yes, sorry. I posted what I thought the php code should look like.
Title: Re: Karma Leaders Block
Post by: Nokonium on March 21, 2006, 07:34:28 PM
Ooops, sorry head like a turnip today. Thanks, I'll try it
Title: Re: Karma Leaders Block
Post by: Nokonium on March 21, 2006, 07:39:50 PM
Parse error: parse error, unexpected T_CLASS in /homepages/6/d119724375/htdocs/Fiddlers-Elbow/Sources/Load.php(1613) : eval()'d code(46) : eval()'d code on line 12

Off to fiddle ...
Title: Re: Karma Leaders Block
Post by: Nokonium on March 21, 2006, 08:00:23 PM
echo' <table
Messes up the left sidebar blocks
Title: Re: Karma Leaders Block
Post by: IchBin on March 22, 2006, 12:57:26 AM
Maybe try setting some sizes on your tables or something. Its hard to say when I can't fiddle myself. :)
Title: Re: Karma Leaders Block
Post by: ontap on March 22, 2006, 05:07:13 AM

i will make a karma block... leave it with me  ;)
Title: Re: Karma Leaders Block
Post by: Nokonium on March 22, 2006, 06:56:00 AM
Quote from: IchBinâ„¢ on March 22, 2006, 12:57:26 AM
Maybe try setting some sizes on your tables or something. Its hard to say when I can't fiddle myself. :)

I went the other way and got rid of the tables, but still a blank block.

echo '<div style="padding: 5px;" class="smalltext">';

global $context, $settings, $options, $scripturl, $txt, $modSettings;

if( $modSettings['karmaMode'] == 1 )
{
echo '<span class="windowbg2"  width="80%" align="left">';

foreach($context['htkarma'] as $htkarma)
{
$total = $htkarma['Good'] - $htkarma['Bad'];'</span>';
echo '<span class="windowbg2" width="20%" align="right">'.$total.'</span>';
}
}
echo '</div>';
Title: Re: Karma Leaders Block
Post by: Nokonium on March 22, 2006, 06:57:38 AM
Quote from: OnTap! on March 22, 2006, 05:07:13 AM

i will make a karma block... leave it with me  ;)

Thanks that is really appreciated  ;D
Title: Re: Karma Leaders Block
Post by: ontap on March 22, 2006, 11:55:47 AM
Quote from: nokonium on March 22, 2006, 06:57:38 AM
Thanks that is really appreciated  ;D

http://www.tinyportal.net/smf/index.php?topic=3630.0 ;)