Grokking Voting API for Community Managed Taxonomy

 
By Benjamin Melançon
on 08 Jul
0 comments

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).

 

Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup> <kbd> <s>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.