Grokking Voting API for Community Managed Taxonomy
I hope this will also be useful to people trying to use votingapi to rate arbitrary content, such as the promised fish.
From votingapi_add_vote
(which should not be called directly, but is used by )
One thing which is incorrect in the module's in-code documentation is this:
@param $value_type
* An int representing the value_type shared by the aggregated votes.
In fact, value_type
is a string, a 20 character varchar. So there's no need to try to look up what integer the standard types map to-- just use the name:
* 'percent' -- 'Value' is a number from 0-100. The API will cache an average for all votes.
* 'points' -- 'Value' is a positive or negative int. The API will cache the sum of all votes.
* 'option' -- 'Value' is an int representing a specific option. The API will cache a vote-count for each option.
On my end I need to make sure that I don't insert duplicate values into my cmt_term_node etc. tables, but instead hand it off to votingapi to count another vote with the same content_id (vapi_id on my end).
I hope this will also be useful to people trying to use votingapi to rate arbitrary content, such as the promised fish.
From votingapi_add_vote
(which should not be called directly, but is used by )
One thing which is incorrect in the module's in-code documentation is this:
@param $value_type
* An int representing the value_type shared by the aggregated votes.
In fact, value_type
is a string, a 20 character varchar. So there's no need to try to look up what integer the standard types map to-- just use the name:
* 'percent' -- 'Value' is a number from 0-100. The API will cache an average for all votes.
* 'points' -- 'Value' is a positive or negative int. The API will cache the sum of all votes.
* 'option' -- 'Value' is an int representing a specific option. The API will cache a vote-count for each option.
On my end I need to make sure that I don't insert duplicate values into my cmt_term_node etc. tables, but instead hand it off to votingapi to count another vote with the same content_id (vapi_id on my end).
Comments
Post new comment