'The following users voted for this node' feature?
angwill - May 17, 2007 - 16:04
| Project: | DrupalIt |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | roychri |
| Status: | needs review |
Description
Hi,
Great module. Really like it.
I was thinking about a little bit of extra functionality for Drupalit that I think would be awesome...
Is there any way the blue box which displays the number of votes so far could link off to a page listing all those users that actually voted on that node?
Cheers...

#1
The answer is yes. I will implement this? There is no answer to this cause I don't know if I do it or not.
#2
+ 1 for this feature!
#3
+1 a nice feature also. :)
#4
here is my solution, theming _drupalit_latest_page in "template.php". i just added an extra parameter, so if your url is like "/drupalit/latest/UID" where UID is your user-id, you should get a list of all users who voted for this.
i whish the output was something more generic, like ... theme ... ('u-list', 'users', ...), but i couldn't find that doc yet. maybe you can help me here.
improvements are welcome!
function YOURTHEMENAME_drupalit_latest_page(){
$output = '';
$who = arg(2);
if (is_numeric($who))
{
drupal_set_title('Votes for node');
$account = user_load(array('uid'=>$who));
if ($account)
{
$result = pager_query(sprintf('SELECT v.uid, v.voted FROM {node} n inner join {drupalit_user_to_vote} v on n.nid = v.nid where n.uid = %d ORDER BY v.voted DESC', $who), variable_get('default_nodes_main', 10));
while ($latest = db_fetch_array($result)) {
$account = user_load(array('uid'=>$latest['uid']));
$output .= '<tr><td>'.theme('user_picture', $account, 'icon').'</td><td>'.theme('username', $account).'</td></tr>';
}
if ($output != '')
$output = '<table>'.$output.'</table>';
}
else
{
$output = 'user not found';
}
}
else
{
$result = pager_query("SELECT dv.nid, dv.first_vote, n.title FROM {drupalit_votes} dv INNER JOIN {node} n ON dv.nid = n.nid ORDER BY dv.first_vote DESC", variable_get('default_nodes_main', 10));
while ($latest = db_fetch_array($result)) {
$node = node_load($latest['nid']);
$output .= node_view($node, TRUE, FALSE);
}
$output .= theme('pager', variable_get('default_nodes_main', 10));
}
return $output;
}
#5
Hi SamStealth, thanks for picking up the ball here. It would be a great asset to be able to show who voted. I tried to implement your solution, but I'm not quite getting what you are doing. It doesn't show the users that voted on the node itself. Would it be possible to alter your solution and show the users that voted on the node itself?
Regards,
Marius
#6
Changing the title back to be more descriptive.
#7
#8
Here is a patch that tansforms the vote number into a clickable element that sends you to a page showing you who else voted.
the cusror is changed to a pointer and a title is put so that when you hover, it says to click here.
Please try it and let me know.
thanks