hey everyone

i was wondering if it's possible to add a forum column with the topic rating implemented
eg, like here but then in a physically forum column

http://www.vbulletin.com/forum/forumdisplay.php?f=55

i've been looking on the fivestar issue page and this forum but haven't found a solution..

i've seen a post where people use a cck field to implement the rating, and then add a new view, etc...
but the forum doesn't have a customizable view (not in the administer pages), so that's useless for me i guess..?

any ideas ?

i 've looked into the theme_forum_topic_list function, but have no idea how to get the topic rating into this function

thanx

Comments

michelle’s picture

If you're not in a big hurry, this will be coming to advforum. Probably not in the next couple weeks, though. I have some broken stuff I need to fix before I add more features.

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

30equals’s picture

hi michelle

thanx for the fast reply.

well, actually i am in a hurry unfortunately enough.

i've playing with the theme_forum_topic_list function, and trying to query the ratings from the votingapi_vote table depending on the nid. this works, but of course the value i get from this is a percentage.

is there a quick way to convert those percentage values to the star rating ?

and is this a good way to do this ;)

thanx

30equals’s picture

so i managed to get what i wanted...sort of..

i'm not a super pro php coder so bare with me.

i customized the theme_forum_topic_list function. i added this after 'foreach($topics as $topic){

 //edit -> implement fivestar rating 
	  $topicid = $topic->nid;
	  $totalrating ="";
  	  $topicrating ="";
	 
	
	
  	  $rating_query = "SELECT * from votingapi_vote WHERE content_id ='$topicid'";
	  $rating_result = mysql_query($rating_query);
	  
	  if (mysql_num_rows($rating_result) > 0){
				
			while($rating_row = mysql_fetch_array($rating_result)){ 
			
				$topicrating = $rating_row["value"];
				
				$totalrating += $topicrating;
				$ratingcounter = mysql_num_rows($rating_result);
				 
			}
		
		
			$topic_number_stars = $totalrating /(20*$ratingcounter);
			$starstring ="";
			
			for ($i = 0; $i<$topic_number_stars;$i++){
			
				$starstring .= "<img src=\"".base_path().path_to_theme()."/images/rating_star.png\" />";			
			
				
			}
		
			$topic -> number_stars = $starstring;
			
		} //end if 
		

	  //end edit

and added the following line in the else part of the $rows array

array('data' => $topic -> number_stars, 'class' => 'rating'),

this probably could have been done better, and if you have any suggestions, the please go ahead.

michelle’s picture

I would use the Fivestar API rather than doing it all manually. But that's all I can suggest until I have time to look into it for advforum.

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

VVN’s picture

with fivestar api:

$current_avg = votingapi_get_voting_result('node', $topic->nid, 'percent', 'vote', 'average');
$topic->number_stars = theme_fivestar_static($current_avg->value);
30equals’s picture

michelle: yeah, i know it would be better to use the fivestar api, but i didn't really have an idea how to implement it in my forum table.

vvn: thanx, i'm going to try that one out.

30equals’s picture

i didn't have the time to reply - but VVN - that works like a charm. thanx!