[« ramsinks] [Main Index] [Working with acrylic: all the technical data »]

greymatter hack: Amazon-style karma


This is a really simple hack to make greymatter's karma feature a lot more useful. This is going to be included in the 1.3a (and later) releases, but for the benefit of anyone running a 1.3 now, here it is. If you don't know what greymatter is, it's a very powerful and flexible blogging tool. It's what I use to maintain this site as a matter of fact.

To install this, you only need to add two lines to gm-library.cgi.

1. Find the text

$thisentrytotalkarma = $thisentrypositivekarma - $thisentrynegativekarma;
and add the following line right below it:
$thisentrytotalkarmavotes = $thisentrypositivekarma + $thisentrynegativekarma;

2. Find the text

$entryreturn =~ s/{{totalkarma}}/$thisentrytotalkarma/gi;
and add the following line right below it:
$entryreturn =~ s/{{totalkarmavotes}}/$thisentrytotalkarmavotes/gi;

At this point you'll have a new template variable, {{totalkarmavotes}} that will let you express karma votes as a number of positive votes out of the total number of votes, just like the "46 of 88 people found this review helpful" you've seen on Amazon.

Something like this in your Karma Form template:

Was this article helpful to you?
<a href="{{positivekarmalink}}">yes</a>/<a href="{{negativekarmalink}}">no</a>
<br>({{positivekarma}} out of {{totalkarmavotes}} readers found this article helpful)

And of course you can customize that to any extent you like with graphic buttons, etc.

text, scripts and images copyright © 2001-2011 . All rights reserved.