Karma On Memberlist

Started by Leaf, November 30, 2005, 10:49:21 PM

Previous topic - Next topic

Leaf

Link to Mod

Written By: Xiaoqing Zhou (Leaf)
Contact info: [email protected]
SMF Board: http://www.anetcity.com/bbs/index.php?board=125.0

This mod shows karma on member list if karma is enabled.

Language supported: English

Rasyr

I really like this Mod a lot, but I have a problem.

I changed what I used Karma for, and have it separated into Laugh Points and Idea Points. So, to use this, I would need to make it display two columns on the Memberlist page, making the Good Karma and Bad Karma into separate columns.

I can make the needed changes in Memberlist.template.php and index.english.php for this, but where I am running into trouble is the memberlist.php from the sources directly. I am either missing something or did something wrong. A little help would be appreciated.

In Memberlist.php I made the following changes

From
'karma' => array(
'label' => $txt['karma'],
'width' => '30'
),


To
'karma' => array(
'label' => $txt['goodkarma'],
'width' => '30'
),
'karma2' => array(
'label' => $txt['badkarma'],
'width' => '30'
),


And From
if (empty($modSettings['karmaMode']))
unset($context['columns']['karma']);


To
if (empty($modSettings['karmaMode']))
unset($context['columns']['karma'])
unset($context['columns']['karma2']);


And From
'karma' => array(
'down' => '(mem.karmaGood - mem.karmaBad) DESC',
'up' => '(mem.karmaGood - mem.karmaBad) ASC'
),


To
'karma' => array(
'down' => '(mem.karmaGood) DESC',
'up' => '(mem.karmaGood) ASC'
),
'karma2' => array(
'down' => '(mem.karmaBad) DESC',
'up' => '(mem.karmaBad) ASC'
),


And after I made these changes, when I tried to load the page, all I got was a blank white page with nothing on it. I know that my changes to other pages did not cause this (the most they did was screw up the formatting of the table, but I was able to separate the karma out into two columns without hassle).

Again, any help would be really really appreciated!!


Leaf

In memberlist.php:

if (empty($modSettings['karmaMode']))
      unset($context['columns']['karma'])
      unset($context['columns']['karma2']);

Replace with :

if (empty($modSettings['karmaMode'])) {
      unset($context['columns']['karma']);
      unset($context['columns']['karma2']);
}

You need to make the corresponding changes in memberlist.template.php to display two seperate points. It seems like you know how to add new columns in table. :)

Gregory

(Laugh Points and Idea Points, ahh a good idea for alternative use)

This mod is quite good, well it's good enough to be one of the few I bother to download/install!

Some notes
-I expected it to show on the admin's member list as this is where I usually go. (ohwell, I suppose it does do what it says).
- I think it is sorting the list by karma points, but in that column it is clearly showing the number of posts not karma points! Surley this isn't just my forum it's done it for. If so what might I of done wrong?
Ant's Life - My morpg that is integrated with SMF for good communications between players and staff.

Leaf

Quote from: Gregory on December 28, 2005, 11:27:24 AM
-I expected it to show on the admin's member list as this is where I usually go. (ohwell, I suppose it does do what it says).
This mod is to address a request some time ago. So, it does what it says.

Quote from: Gregory on December 28, 2005, 11:27:24 AM
- I think it is sorting the list by karma points, but in that column it is clearly showing the number of posts not karma points! Surley this isn't just my forum it's done it for. If so what might I of done wrong?
It is sorting on the total of karmaGood and karmaBad (KarmaGood - KarmaBad). You can change the sorting criteria manually after you apply the mod. If you get wrong data, it is probably because you place the wrong data source in memberlist.template.php.

Gregory

#5
I just installed the mod in package manager (SMF 1.05 so I shouldnt of needed to manually do anything?)

Memberlist.template.php
I think the number of posts is actually supposed to be there, and the karma column has not been put in.
below the columns is // No members?
else
echo '
<tr>
<td colspan="', isset($context['columns']['karma']) ? '13' : '12', '" class="windowbg">', $txt[170], '</td>
</tr>';

So it will display the karma amount if there are no members  :P


Edit: I'm trying to fix this myself.
How do I get the karma to display? $member['karma'] doesnt exist when I output $member. Does this mean I have further problems?
Ant's Life - My morpg that is integrated with SMF for good communications between players and staff.

Rasyr

Quote from: Gregory on December 28, 2005, 11:27:24 AM
(Laugh Points and Idea Points, ahh a good idea for alternative use)

Thanks. A number of my users had concerns about karma in and of itself. So in the Admin section for Karma, I changed the labels. Then in the display.template.php and the PersonalMessage.template.php I changed the code where it displayed it (if turned on), so that it separated the good from the bad karma, and displayed them on separate lines with individual labels.

Look here to see what it looks like.

Rasyr

Quote from: Leaf on December 28, 2005, 10:29:20 AM
In memberlist.php:

if (empty($modSettings['karmaMode']))
      unset($context['columns']['karma'])
      unset($context['columns']['karma2']);

Replace with :

if (empty($modSettings['karmaMode'])) {
      unset($context['columns']['karma']);
      unset($context['columns']['karma2']);
}

You need to make the corresponding changes in memberlist.template.php to display two seperate points. It seems like you know how to add new columns in table. :)

Thanks!! That made it work beautifully. Figures it would be something as silly as needing to group the two lines after the if statement... heheh

Leaf

#8
Quote from: Gregory on December 28, 2005, 01:03:26 PM
I just installed the mod in package manager (SMF 1.05 so I shouldnt of needed to manually do anything?)

Memberlist.template.php
I think the number of posts is actually supposed to be there, and the karma column has not been put in.
below the columns is // No members?
else
echo '
<tr>
<td colspan="', isset($context['columns']['karma']) ? '13' : '12', '" class="windowbg">', $txt[170], '</td>
</tr>';

So it will display the karma amount if there are no members  :P


Edit: I'm trying to fix this myself.
How do I get the karma to display? $member['karma'] doesnt exist when I output $member. Does this mean I have further problems?
This mod is for smf 1.1 and only tested on smf 1.1 rc1. For smf 1.0.5, you need manually apply this mod. I think you get all other changes except the change to assign value to $member['karma'].

In memberlist.php, search for:

$context['members'][$row['ID_MEMBER']]['website']['link'] = $row['websiteUrl'] != '' ? '<a href="' . $row['websiteUrl'] . '" target="_blank"><img src="' . $settings['images_url'] . '/www.gif" alt="' . htmlspecialchars($context['members'][$row['ID_MEMBER']]['website']['title']) . '" title="' . htmlspecialchars($context['members'][$row['ID_MEMBER']]['website']['title']) . '" border="0" /></a>' : '';


Add after the above line:

// If karma enabled show the members karma.
if ($modSettings['karmaMode'] == '0')
$context['members'][$member]['karma']['display'] = '';
elseif ($modSettings['karmaMode'] == '1')
$context['members'][$member]['karma']['display'] = $context['members'][$member]['karma']['good'] - $context['members'][$member]['karma']['bad'];
elseif ($modSettings['karmaMode'] == '2')
$context['members'][$member]['karma']['display'] = '+' . $context['members'][$member]['karma']['good'] . '/-' . $context['members'][$member]['karma']['bad'];

Gregory

I don't know why I thought the mod was for 1.05 but I really wish I hadn't of touched it now!!!

Anyway, with some manual following of the mod I have got it working.
Just now my member list has a quirk of every page of results has a mystery second member where every field is blank except karma is 0.

Thanks for your help, I'm going to leave it as it is now.
Ant's Life - My morpg that is integrated with SMF for good communications between players and staff.

Leaf

I updated the mod to support 1.0.5 and 1.1 rc2.

Greqory, you can try the new one.

LostProphecy

Quote from: Rasyr on December 24, 2005, 11:52:52 AM
I really like this Mod a lot, but I have a problem.

I changed what I used Karma for, and have it separated into Laugh Points and Idea Points. So, to use this, I would need to make it display two columns on the Memberlist page, making the Good Karma and Bad Karma into separate columns.


omg thank you for the fantastic idea... for a long time i've wanted to have 2 systems of karma but was never smart enough to work it out for myself... you are like a legend... i'm going to do that now :D
Angelus Ex Quo Nox


NukeWorker.com

Quote from: Leaf on January 02, 2006, 09:18:17 PM
I updated the mod to support 1.0.5 and 1.1 rc2.

Greqory, you can try the new one.

QuoteInstallations actions for "Karma On Memberlist":
Installing this package will perform the following actions:  Type Action Description
1. Execute Modification ./Sources/Memberlist.php Test successful
2. Execute Modification ./Themes/default/Memberlist.template.php Test failed
3. Execute Modification ./Themes/default/languages/index.english.php Test successful

Powered by SMF 1.1 RC2
   

Leaf

I tested again on 1.1 rc2. No problem for me. Memberlist.template.php failed probably because you have installed another mod that modified that file to add a new column in the list.

NukeWorker.com

Quote from: Leaf on January 13, 2006, 10:57:21 AM
I tested again on 1.1 rc2. No problem for me. Memberlist.template.php failed probably because you have installed another mod that modified that file to add a new column in the list.

I'm running an unmodified install.  Fresh 1.1 RC 2.

Leaf

#16
Quote from: NukeWorker.com on January 13, 2006, 01:59:03 PM
I'm running an unmodified install.  Fresh 1.1 RC 2.
How can it be? I tested on a fresh 1.1 RC2 with Chinese language pack. A moment ago, I installed a fresh 1.1 RC2 English version. I got no error on either forum. Are you sure you downloaded the lastest mod?

Skipdawg

Nice Mod!  ;)
Loaded with no issues at all on 1.0.5, 1.1 rc1 and 1.11 rc2  :)

A very nice addition to the member list information  ;)
Skipdawg's Community

Powered by SMF 1.1.3

Grumelo

I have an issue with this mod.
Check my screenshot [nofollow].

Leaf

Quote from: Grumelo on January 31, 2006, 03:58:25 PM
I have an issue with this mod.
Check my screenshot.
You have wrong number of table columns. The original column number is 12.

For smf1.1rc2, this mod changes the following parts in Memberlist.template.php:

Search for:
         <td colspan="12">';
Replace with:
         <td colspan="', isset($context['columns']['karma']) ? '13' : '12', '">';

Search for:
         <td colspan="12" class="', empty($settings['use_tabs']) ? 'catbg' : 'titlebg', '">';
Replace with:
         <td colspan="', isset($context['columns']['karma']) ? '13' : '12', '" class="', empty($settings['use_tabs']) ? 'catbg' : 'titlebg', '">';

Search for:
         <td class="windowbg" align="left">', $member['registered_date'], '</td>
Add after:
         ', isset($context['columns']['karma']) ? '
         <td class="windowbg2" width="15">' . $member['karma']['display'] . '</td>' : '', '

Search for:
         <td colspan="12" class="windowbg">', $txt[170], '</td>
Replace with:
         <td colspan="', isset($context['columns']['karma']) ? '13' : '12', '" class="windowbg">', $txt[170], '</td>

Search for:
         <td class="titlebg" colspan="12">', $txt[139], ': ', $context['page_index'], '</td>
Replace with:
         <td class="catbg" colspan="', isset($context['columns']['karma']) ? '13' : '12', '">', $txt[139], ': ', $context['page_index'], '</td>

Are you sure you have all these changes in that file? If not, just manually add them.

Advertisement: