Voting API: Count not showing up in views

calebm12 - July 2, 2009 - 23:58

I am using the Voting API with drupalit module to allow users to vote on nodes. I am working now on establishing views and am having a difficult time getting the number of votes to show up as a field. I have established the voting api relationship and have place a voteapi value in the field however even though the node has one vote it is showing the count as 0. Its like the connection is not being made or something. the site is on a local host...does this make a difference? any idea what is happening?

nevermind. got it. didnt

calebm12 - July 3, 2009 - 00:15

nevermind. got it. didnt have an appearance for druaplit field set....it on on default apperance.

Setup

the_paulus - September 1, 2009 - 18:31

Just out of Curiousity, How do you have your views set up and are you only displaying the number of votes? What voting module are you using (ie Fivestar)?

Hi, you can use below code in

rashmi.cms - July 3, 2009 - 07:37

Hi,

you can use below code in your view.tpl file in order to display total vote per node.

<?php
$tag
= isset($variables['tag']) ? $variables['tag'] : variable_get('vote_up_down_tag', 'vote');
   
$criteria = array(
   
'content_type' => 'node',
   
'content_id' => $node->nid,
   
'value_type' => 'points',
   
'tag' => $tag,
   
'function' => 'sum'
   
);
  
$vote_result = (int)votingapi_select_single_result_value($criteria);
   print
'<div class="home-vote-count">'.$vote_result.'</div>';
?>

Hope it will help you.

Regards
Rashmi

 
 

Drupal is a registered trademark of Dries Buytaert.