Needs review
Project:
Voting
Version:
master
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
3 Oct 2005 at 10:24 UTC
Updated:
20 Sep 2007 at 20:20 UTC
Hi,
I needed display user(s) rating for node, on preview node (it looks like: "Posted in Action | add new comment | read more | 8 reads »", so it will look like "Posted in Action | add new comment | read more | 8 reads | rating: 2.00 »"
So here is code:
- open modules/voting/voting.module
- add:
/**
* Implementation of hook_link().
*/
function voting_link($type, $node = 0, $main = 0) {
$links = array();
if ($type == 'node') {
$rating = db_fetch_array(db_query('SELECT sum(vote)/count(content_id) as rating from votes where content_id = %d', $node->nid));
if ($rating) $links[] = $rating['rating'] ? "rating: " . $rating['rating'] : "rating: no votes";
}
return $links;
}
- save file
Ofcourse there should be nice configuration for module within admin->settings->voting, if display this, or not, but this maybe next time :) (it is not big issue)
Enjoy
Comments
Comment #1
Dabitch commented"from votes" - don't you mean "from node_voting"...?
Comment #2
Dabitch commentedSpoke too soon, I guess I'm just wondering which table(s) you're gathering this from? I think It's a cool idea.