Closed (fixed)
Project:
Voting API
Version:
5.x-1.6
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
25 May 2008 at 02:39 UTC
Updated:
6 Jun 2008 at 02:15 UTC
I try to implement something like amazon or newegg's interface: give a summary of votings. and list the percentage for each score, from 1 to 5. please see the screenshot i have attached.
I guess i can get it by doing my own SQL query from votingapi's tables to get the percentage (or count) of each rank. but wanted to ask if there is any API which has already had it covered.
thanks.
| Comment | File | Size | Author |
|---|---|---|---|
| newegg.png | 3.87 KB | xqi | |
| amazon.png | 4.38 KB | xqi |
Comments
Comment #1
quicksketchYou can do this by leveraging the functions of VotingAPI. Since this has to do with the retrieval of data rather than the Fivestar interface, I've moved to ticket over there.
You can get a raw collection of all votes by using the
votingapi_get_voting_results('node', $nid)function. However, this would probably retrieve a lot more information that you need, since it would retrieve all the voting tags (not just 'vote' or whatever axis it is that you're rating on). To get more complicated there's the_votingapi_get_raw_votes()function which I'm not sure if it'd be better or worse than making a direct SQL query. Drupal 6's votingAPI 2 is much more flexible in this regard, but for D5, a direct query might be the best way to go.Comment #2
xqi commentedthank you quicksketch. i will directly query the field table for now.
Comment #3
eaton commented