Last updated February 10, 2012. Created by PGiro on June 13, 2006.
Edited by torotil, shopdogg, ericbroder, dajpanspokoj. Log in to edit this page.
VotingAPI is a flexible, easy-to-use framework for rating, voting, moderation, and consensus-gathering modules in Drupal. It allows module developers to focus on their ideas (say, providing a 'rate this thread' widget at the bottom of each forum post) without worrying about the grunt work of storing votes, preventing ballot-stuffing, calculating the results, and so on.
VotingAPI does four key jobs for module developers:
- CRUD: Create/Retrieve/Update/Delete operations for voting data. The simplest modules only need to call two functions -- votingapi_set_vote() and votingapi_get_voting_results() -- to use the API. Others can use finer-grain functions for complete control.
- Calculation: Every time a user casts a vote, VotingAPI calculates the results and caches them for you. You can use the default calculations (like average, total, etc) or implement your own custom tallying functions.
- Workflow: By integrating with Actions.module, VotingAPI can trigger workflow steps (like promoting a node to the front page, hiding a comment that's been flagged as spam, or emailing an administrator) when votes are cast and results are tallied. Modules can expose their own 'default' action sets and filter criteria to provide moderation and promotion systems.
- Display: VotingAPI integrates with Views.module, allowing you to slice and dice your site's content based on user consensus. It also provides convenience functions to format vote data for display to users.
If you're a Drupal user looking for a voting or rating module (rather than just a framework), or you're a developer looking for examples of VotingAPI based code, check out some of the following projects:
- Rate
- Decisions (no D7 version)
- Fivestar
- NodeReview (D7 dev)
- Vote Up/Down (D7 git)
- Plus 1 (D7 dev)
Modules that are no longer actively maintained (may be easy to update and have interesting ideas on how to write a VotingAPI module):
Comments
Documentation Lacking
Documentation is somewhat lacking for Voting API.
Fortunately, the inline documentation within the votingapi.module file is extremely helpful. Here is the Lullabot API page for it: http://api.lullabot.com/file/contrib/votingapi/votingapi.module/
Most developers that are implementing VotingAPI in their module need to take a look here: http://api.lullabot.com/votingapi_set_votes
Enjoy!
- Jeremy
Activism Labs
Links are helpful
Thanks for the direction