News:

Wondering if this will always be free?  See why free is better.

Main Menu

Karma images - not text

Started by evillair, May 25, 2007, 10:46:10 AM

Previous topic - Next topic

evillair

Would it be easy to have the karma of people display in images not text?

I searched but nothing came up. :\

I was thinking of:
if karma 1 to 10 = Kimage1.gif
if karma 11 to 20 = Kimage2.gif
etc..

Then at the end it would be: karma >100 = KimageFull.gif

So the image would replace the current example: "Karma: 16".


Thanks in advance.


Kays

There has been discussion on it lately and I think someone might be looking into putting a weighted system together like vB.

But if you want to try it your self it's not that difficult. The member's karma count is available and the easiest way to do it is a series of elsif statements starting at the highest numbers.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

evillair

ok thanks.

I already tried that's why I'm asking, it's too complex for me to do.
I'll keep messing with it.

Kays

#3
But that's how you learn. :)

I don't know if this would suite you, it's what I use. I wrote it quite some time ago so it probably could be done better.

What this does is display a progerss bar at the bottom and a pip on top. every five karma points a new pip is added and the bar is reset. And for each 50 points or 10 pips a gold bar is shown. You'll need to place two images into the images folder of the theme you're using. A pip named pip.gif which is 10x10 and the gold_bar.gif which is 7x100

 

In Display.template.php in the theme you're using find:

// Is karma display enabled?  Total or +/-?
if ($modSettings['karmaMode'] == '1')
echo '
<br />
', $modSettings['karmaLabel'], ' ', $message['member']['karma']['good'] - $message['member']['karma']['bad'], '<br />';
elseif ($modSettings['karmaMode'] == '2')



and replace it with:


// Is karma display enabled?&nbsp; Total or +/-?
if ($modSettings['karmaMode'] == '1') {
$karma = $message['member']['karma']['good'] - $message['member']['karma']['bad'];
$num_bars = 0;
$num_pips = 0;
echo '<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr><td width="100%" align="center"colspan="2"><img src="' . $settings['images_url'] . '/blank.gif" height="5" alt="" border="0" /></td></tr>';
//==>> count bars if rep > 50
if ($karma >= 50)
$num_bars = floor($karma/50);

//==>> display pips
if ($num_bars > 0)
$karma = $karma - $num_bars*50;

if ($karma > 0 || empty($message['member']['karma']['good'])) {
$num_pips = floor($karma/5)+1;
$cnt = 1;
echo'
<tr><td align="left" colspan="2">';

while ($num_pips >= $cnt) {
echo '<img src="' . $settings['images_url'] . '/pip.gif" alt="" border="0" />';
$cnt++;
}
}
echo '</td></tr>';
//==>> display gold bars
$cnt = 1;
echo'
<tr><td colspan="2">';
while ($num_bars >= $cnt) {
echo '<img src="' . $settings['images_url'] . '/gold_bar.gif" height="7" width="100" alt="" border="0" /><br />';
$cnt++;
}
echo '</td></tr>';
//==>> positive rating bar
if ($karma > 0 || empty($message['member']['karma']['good'])) {
$rating = $karma - (($num_pips-1)*5);
echo'
<tr>
<td style="background-color:#6A95B7;" width="' , $rating*20+5 , '%"></td><td style="background-color:#C0C0C0;"><img src="' . $settings['images_url'] . '/blank.gif" height="7" alt="" border="0" /></td>
</tr>';
//==>> negative rating bar
} else {
echo'
<tr>
<td&nbsp; style="background-color:black;" width="' . ($karma*(-10)+1) . '%"></td><td style="background-color:#C0C0C0;"><img src="' . $settings['images_url'] . '/blank.gif" height="7" alt="" border="0" /></td>
</tr>';
}
echo '</table>'; //==>> close table
}

if ($modSettings['karmaMode'] == '2')

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

evillair

Great thanks!

I'll work with that :)

evillair

#5
Sorry for double posting, but I got it work...

My test...


if ($modSettings['karmaMode'] == '1')
{
$karma = $message['member']['karma']['good'] - $message['member']['karma']['bad'];
// count karma
if ($karma <= 100)
echo' LESS then 100! <br />';
if ($karma >= 20)
echo' MORE then 20! <br />';
if ($karma >= 10)
echo' MORE then 10! <br />';
if ($karma <= 20)
echo'  LESS then 20! <br />';
if ($karma == 15)
echo'  Yes, you have 15!     <br />';
}



Gives me this:



I set it so I had +15.
Now it's just adding images. :)

How do I do a & statement though? 
like... ($karma <= 100 & $karma >= 50) ? I can't get the syntax correct.



Thank a lot Kays! Your code helped me figure it out. Was simple as you had said.

EDIT:
Got it working way better:


if ($modSettings['karmaMode'] == '1')
{
$karma = $message['member']['karma']['good'] - $message['member']['karma']['bad'];

if ($karma <= 200 && $karma >= 100)
{
$karmagif = '<div style="overflow: auto;"><img src="' . $settings['images_url'] . '/img/karma_high.gif" alt="" border="0" /></div>';
}
else if ($karma <= 100 && $karma >= 50)
{
$karmagif = '<div style="overflow: auto;"><img src="' . $settings['images_url'] . '/img/karma_mid.gif" alt="" border="0" /></div>';
}
else if ($karma <= 50 && $karma >= 20)
{
$karmagif = '<div style="overflow: auto;"><img src="' . $settings['images_url'] . '/img/karma_norm.gif" alt="" border="0" /></div>';
}
else if ($karma <= 20 && $karma >= 0)
{
$karmagif = '<div style="overflow: auto;"><img src="' . $settings['images_url'] . '/img/karma_low.gif" alt="" border="0" /></div>';
}
echo' ', $karmagif , '<br />';

}



My mini reputation system :)


N3lson

Quote from: Kays on May 25, 2007, 09:02:08 PM
But that's how you learn. :)

I don't know if this would suite you, it's what I use. I wrote it quite some time ago so it probably could be done better.

What this does is display a progerss bar at the bottom and a pip on top. every five karma points a new pip is added and the bar is reset. And for each 50 points or 10 pips a gold bar is shown. You'll need to place two images into the images folder of the theme you're using. A pip named pip.gif which is 10x10 and the gold_bar.gif which is 7x100

 

In Display.template.php in the theme you're using find:

// Is karma display enabled?  Total or +/-?
if ($modSettings['karmaMode'] == '1')
echo '
<br />
', $modSettings['karmaLabel'], ' ', $message['member']['karma']['good'] - $message['member']['karma']['bad'], '<br />';
elseif ($modSettings['karmaMode'] == '2')



and replace it with:


// Is karma display enabled?  Total or +/-?
if ($modSettings['karmaMode'] == '1') {
$karma = $message['member']['karma']['good'] - $message['member']['karma']['bad'];
$num_bars = 0;
$num_pips = 0;
echo '<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr><td width="100%" align="center"colspan="2"><img src="' . $settings['images_url'] . '/blank.gif" height="5" alt="" border="0" /></td></tr>';
//==>> count bars if rep > 50
if ($karma >= 50)
$num_bars = floor($karma/50);

//==>> display pips
if ($num_bars > 0)
$karma = $karma - $num_bars*50;

if ($karma > 0 || empty($message['member']['karma']['good'])) {
$num_pips = floor($karma/5)+1;
$cnt = 1;
echo'
<tr><td align="left" colspan="2">';

while ($num_pips >= $cnt) {
echo '<img src="' . $settings['images_url'] . '/pip.gif" alt="" border="0" />';
$cnt++;
}
}
echo '</td></tr>';
//==>> display gold bars
$cnt = 1;
echo'
<tr><td colspan="2">';
while ($num_bars >= $cnt) {
echo '<img src="' . $settings['images_url'] . '/gold_bar.gif" height="7" width="100" alt="" border="0" /><br />';
$cnt++;
}
echo '</td></tr>';
//==>> positive rating bar
if ($karma > 0 || empty($message['member']['karma']['good'])) {
$rating = $karma - (($num_pips-1)*5);
echo'
<tr>
<td style="background-color:#6A95B7;" width="' , $rating*20+5 , '%"></td><td style="background-color:#C0C0C0;"><img src="' . $settings['images_url'] . '/blank.gif" height="7" alt="" border="0" /></td>
</tr>';
//==>> negative rating bar
} else {
echo'
<tr>
<td  style="background-color:black;" width="' . ($karma*(-10)+1) . '%"></td><td style="background-color:#C0C0C0;"><img src="' . $settings['images_url'] . '/blank.gif" height="7" alt="" border="0" /></td>
</tr>';
}
}

if ($modSettings['karmaMode'] == '2')



That was nice but the code maybe is not correct because it changes all display of the posts
I´m Portuguese Yeah

Tanks

At first i had big problems with the code Kayes posted but i found out some table was not closed..

Here is what it looks like over at my site



here is the code (notice i changed the pip image to PNG)



// Is karma display enabled?  Total or +/-?
if ($modSettings['karmaMode'] == '1') {
$karma = $message['member']['karma']['good'] - $message['member']['karma']['bad'];
$num_bars = 0;
$num_pips = 0;
echo '<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr><td width="100%" align="center"colspan="2"><img src="' . $settings['images_url'] . '/blank.gif" height="5" alt="" border="0" /></td></tr>';
//==>> count bars if rep > 50
if ($karma >= 50)
$num_bars = floor($karma/50);

//==>> display pips
if ($num_bars > 0)
$karma = $karma - $num_bars*50;

if ($karma > 0 || empty($message['member']['karma']['good'])) {
$num_pips = floor($karma/5)+1;
$cnt = 1;
echo'
<tr><td align="left" colspan="2">';

while ($num_pips >= $cnt) {
echo '<img src="' . $settings['images_url'] . '/pip.png" alt="" border="0" />';
$cnt++;
}
}
echo '</td></tr>';
//==>> display gold bars
$cnt = 1;
echo'
<tr><td colspan="2">';
while ($num_bars >= $cnt) {
echo '<img src="' . $settings['images_url'] . '/gold_bar.gif" height="7" width="100" alt="" border="0" /><br />';
$cnt++;
}
echo '</td></tr>';
//==>> positive rating bar
if ($karma > 0 || empty($message['member']['karma']['good'])) {
$rating = $karma - (($num_pips-1)*5);
echo'
<tr>
<td style="background-color:#6A95B7;" width="' , $rating*20+5 , '%"></td><td style="background-color:#C0C0C0;"><img src="' . $settings['images_url'] . '/blank.gif" height="7" alt="" border="0" /></td>
</tr></table><br>';
//==>> negative rating bar
} else {
echo'
<tr>
<td  style="background-color:black;" width="' . ($karma*(-10)+1) . '%"></td><td style="background-color:#C0C0C0;"><img src="' . $settings['images_url'] . '/blank.gif" height="7" alt="" border="0" /></td>
</tr></table><br>';
}
}
elseif ($modSettings['karmaMode'] == '2')
echo '
<br />
<b>', $modSettings['karmaLabel'], '</b> +', $message['member']['karma']['good'], '/-', $message['member']['karma']['bad'], '<br />';


Kays

Sorry about omiting that </table>. I had it right at the end and missed it.

But I'm glad that both of you were able to do something with it.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

N3lson

Look mine ... with a personal coding...

I´m Portuguese Yeah

Kays

Nice, I like the +/- buttons. :)

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

N3lson

 

Here you go ....

Do you like the bar to?
I´m Portuguese Yeah

Tanks

I use these

kinda big.. but thats how my site is designed :D


Kays


If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

trenchteam

I would be great to package this one up!!! ;D

evillair

If you add:

<a href="'. $message['member']['href']. '" title="'. $modSettings['karmaLabel']. ' +'. $message['member']['karma']['good']. '">
With an ending </a> to your images, you'll get a tooltip with the users karma level. ex: (Karma: +203)

Could be a nice touch.



Kays

Nice idea, I didn't think of that. :)

Except that you should use $karma instead since it shows the combined +/- karma.

Quote from: trenchteam on May 26, 2007, 06:42:03 PM
I would be great to package this one up!!! ;D

I'm not interested in packaging it because it's a skin mod and will only be added to the default skin. I suspect that most who would want this also use a custom skin, so it would involve a manual install anyways. Leaving it here shows people that it can be customised. There are some good examples here of what can be done with it. :)

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

dyota

How's about negative karma? is it included in this script?

Kays

Yes, a black bar will appear and no pips. :)

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

dyota

I wanna reps such as Kays but with my own icon attached

i'll place the icon in www.mysite.com/forum/images

yellow icon for every 10 positive karma
green icon for every 10 positive karma, after 5 yellow icon

black icon for every 10 negative karma
bad icon for every 10 negative karma after 5 bad icon

up icon to add positive karma
down icon to add negative karma   

Could you give me the script? Thanks a lot

ilustration:




icon:
http://www.filesend.net/download.php?f=54b4995a3d7aaf2e40455fc965176518

Advertisement: