Hi,

I have installed the module and all seems to be working correctly except for the fact I cannot seem to find the block to display the top ranked Karma users. Have searched here for it and it appears to be automatically activated but this is definitely not case for my site.
Any thoughts?

Thanks in advance.

Clement

Comments

Apollo610’s picture

With Karma's VotingAPI-related VIEWS integration, you should be able to create a simple block view to display per your requirements.

That's most likely what was done on the sites you've seen with a Karma block if a block wasn't part of the Karma install.

Apollo610’s picture

Title: Best Karma Users block » Best Karma Users block - an example

In response to integrating User Karma with Blocks, I've found a way to implement them if you want to tie back user karma info to users.

My config: I'm using User Karma strictly as an Up/Down mechanism for comments (as I'm using Fivestar for more robust node rating).
My need: To create a "Best of" User Karma block that would display the top 5 User Karma contributors for the day.

Modules needed: Views, CCK, CCK Computed Field, Content Profile, User Karma, Voting API

The content profile module turns profiles into nodes, which is key since we'll need to add a CCK field and then access it via Views. We can't do this with standard profiles.

How To:
1) Install and enable all the above modules.
2) Edit the content type "Profile" and make sure the "Content Profile" checkbox at the bottom is checked.
3) In Edit Content Type>Profile, go to "Manage fields" and add a Computed field (this will become an option in the dropdown when the CCK Computed Field module is enabled).
4) Add the query that will calculate the data you're looking for (in my case, I wanted to pull the total current user karma so I added this to the computed code area:

 global $user;
$node_field[0]['value'] = db_result(db_query("SELECT value FROM votingapi_vote vv where vv.value_type='karma_points' and vv.content_id = $user->uid"));

and added this to the display code (so I could verify the field, although ultimately I will make this hidden)

 global $user;
$display = db_result(db_query("SELECT value FROM votingapi_vote vv where vv.value_type='karma_points' and vv.content_id = $user->uid"));

5) Check "Store using database settings below" -- this is required so that Views will see the field. Setup the database settings as you need, and save the field. Then save the content type and you're all set.
6) Go into View, add a new view of type "Users".
7) Under "Relationships" select "Node: Content Profile" and update so it saves.
8) Under "Fields" the User Karma field that you had create in steps #3-5 above should be visible. Add it, and whatever other fields you wish to display (in my case I chose User Name, User Picture).

View should preview the output, and you should see the correct information. With CCK Computed Field you should be able to do a number of variations of this, giving User Karma a bit more views flexibility when it comes to users.

If anyone has a better way of doing this please let me know - this is painful but it works. The only problem I see with this right now is that for the query to be refreshed to pull the most updated karma #, I'll need to force a manual refresh on the CCK Computed Field that was created so that the query runs and the new value gets updated. Still need to figure out the logistics of this.

Hope this helps someone as I spent the better part of today pulling my hair out trying to figure this out.

mercmobily’s picture

Status: Active » Fixed

Hi,

I can confirm that User Karma doesn't have a block on its own -- you can have a list of top karma users with snipsets, or with views.

This solution is quite involved but also quite neat! Thank you Apollo610

Bye,

Merc.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

socialnicheguru’s picture

subscribing

socialnicheguru’s picture

Version: 5.x-1.13 » 6.x-1.x-dev

Is there a way to do this in Drupal 6 with views?

I have tried, but inorder to get the voting api, you need to call a node. I thought user karma was associated with $user.

I tried to do it with views2
add node:voting api results
relationship with a node content profile
add field voting api result

I get this-

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= votingapi_cache_node_karma_points_karma_sum.content_id AND (votingapi_cache_no' at line 12 query: SELECT users.uid AS uid, votingapi_cache_node_karma_points_karma_sum.value AS votingapi_cache_node_karma_points_karma_sum_value, node_data_field_user_karma.field_user_karma_value AS node_data_field_user_karma_field_user_karma_value, node_users.nid AS node_users_nid, node_users.type AS node_users_type, node_users.vid AS node_users_vid FROM users users LEFT JOIN node node_users ON users.uid = node_users.uid AND node_users.type = 'profile_personal' LEFT JOIN node node_users_1 ON users.uid = node_users_1.uid AND node_users_1.type = 'profile_professional' LEFT JOIN node node_users_2 ON users.uid = node_users_2.uid AND node_users_2.type = 'profile_educational' LEFT JOIN node node_users_3 ON users.uid = node_users_3.uid AND node_users_3.type = 'profile_service' INNER JOIN votingapi_cache votingapi_cache_node_karma_points_karma_sum ON .nid = votingapi_cache_node_karma_points_karma_sum.content_id AND (votingapi_cache_node_karma_points_karma_sum.content_type = 'node' AND votingapi_cache_node_karma_points_karma_sum.value_type = 'karma_points' AND votingapi_cache_node_karma_points_karma_sum.tag = 'karma' AND votingapi_cache_node_karma_points_karma_sum.function = 'sum') LEFT JOIN content_type_profile_personal node_data_field_user_karma ON node_users.vid = node_data_field_user_karma.vid ORDER BY votingapi_cache_node_karma_points_karma_sum_value DESC LIMIT 0, 20 in /drupal/sites/all/modules/views/includes/view.inc on line 731.