How to Vote in Drupal's Voting API Interface

The Voting API module lets you integrate a voting feature into your Drupal site that allows users to vote whether or not they like content. The Voting API module does not come with a complete voting system. Instead, it provides a framework for other modules that integrate the voting system with Drupal. You can download complete voting modules, but if you want to code your own voting system, use the "votingapi_set_votes" command to allow users to vote on your site's content.

Instructions

    • 1

      Open the PHP file for the module you are trying to code using Voting API. You can open the file in Notepad or in a file-management system provided by your Web host.

    • 2

      Locate the place in your script where you want users to vote, and type the following:

      <?php
      function votingapi_set_votes(&$votes, $criteria = NULL) {
      $touched = array();
      if (!empty($votes['content to vote on'])) {
      $votes = array($votes);
      }

      Replace "content to vote on" with the Content ID for the content on which you want users to vote.

    • 3

      Save and close the PHP file.

Tips & Warnings

  • Find several modules that use the Voting API module by searching the Drupal module database for "vote."

Related Searches:

References

Comments

Related Ads

Featured