Adding Karma Points to DiscussionFilterModule

I'm helping out @okhawaja with some things and one is extending the functionality of the Karma Bank. I just wanted to share this if anybody is interested. Adding this to a custom theme (or a plugin) will add a link to the Karma Bank profile page to the discussion filter module (below "My Drafts").

Personally I do not think that this is a good place for this because Karma Points simply are no discussions, but I think making the balance permanently visible is a good thing.

By the way: the Karma Bank plugin is written very well and can be extended easily!
e.g.: one thing I don't like is that Karma is presented as floating point values. But x00 made it easy to customize that. If anybody prefers another number format, it can be solved by using a custom translation.

Create following file: /conf/locale.php and add following code in there

<?php
$Definition['KarmaBank.NumberFormat'] = '%d';

This is the format that the php function printf uses to fomat Karma points when they are rendered to screen and in my case I choose %d to see integer values.

Comments

how do you create a theme hook file? I am using Bittersweet theme and inside the theme/bittersweet I created a file called "class.bittersweetthemehooks" and then I entered this code:

<?php

class bittersweetThemeHooks implements Gdn_IPlugin {

//entered your code in discussion here

}

Is this how you create a theme hook if your theme doesn't have one? my MinusBaseline theme has a themehook file, but Bittersweet doesn't so I am not sure for Bittersweet how to create a themehook file.

@okhawaja said:
how do you create a theme hook file? I am using Bittersweet theme and inside the theme/bittersweet I created a file called "class.bittersweetthemehooks" and then I entered this code:

<?php

class bittersweetThemeHooks implements Gdn_IPlugin {

//entered your code in discussion here

}

Is this how you create a theme hook if your theme doesn't have one? my MinusBaseline theme has a themehook file, but Bittersweet doesn't so I am not sure for Bittersweet how to create a themehook file.

why are you changing core files?

Much better to create a new theme with your own name. and create a "themehooks" file with a class name and file name that matches your newly created theme in your newly created theme folder.

I bet he is doing that because he isn't aware that even adding a file could be seen as changing.

In this case you, okhawaja, would loose your work if the next update of Vanilla would come with its own themehook file for bittersweet.
Also it would be hard to help if e.g. you tell people you deactivated all plugins and only use the bittersweet theme: a themehook file is nothing else than a plugin.

So the right way to add a themehook file is first to create your own theme. This could simply be done by copying the bittersweet folder to "myBittersweet". Afterwards you have to reflect this new name in /themes/myBittersweet/about.php
Look at these to lines in this file:

$ThemeInfo['bittersweet'] = array(
'Name' => 'Bitter Sweet',

replace "bittersweet" with "myBittersweet" and "Bitter Sweet" with "My Bitter Sweet". That's all you have to do to create your own theme where you can change, add, delete anything you like!

The way you've added the themehooks file was absolutely correct. Do it the same way (with the new name everywhere) in your new themes folder. There s only one part missing in your themehooks file: every themehook file must have a method setup(), but this doesn't have to do anything. So simply add this to your themehooks file: