Khách viếng thăm vote trên website bằng voting.module

Khách viếng thăm vote trên website bằng voting.module

Your website visitors made the effort of voting on your site, now let's reward them with points.

Install these modules first

(these versions or higher)
Voting API 7.x-2.4
Fivestar 7.x-2.0-alpha1 (or another voting thingy that works with Voting API)
Voting Rules 7.x-1.0-alpha1
User Points 7.x-1.0

Be sure to enable Userpoints rules Integration (its part of the Userpoints module).

enabling Userpoints module

Adding Fivestar

Add a Fivestar Rating Field to the content type you'd like to rate.

Fivestar field Structure

Creating the Rule

Go to /admin/config/workflow/rules and add a new Rule:

Add the Rule

You can name ot whatever you like, in this example we'll call it 'user votes on a node'.

Rule Event User Votes on a Node

Select 'Voting API -> User votes on a Node' as event and save.

Now as a Rule event select 'Points-> Grant points to a user'

Rule event for granting User points

As user Data selector type (or click) site:current-user and input the points value, points category value, operation value, description value and moderate value:

Rule Event operation value and description

Userpoints moderate rule Setting

and save.

Don't forget to add a Rule condition that says 'node is of type' or 'Entity has Field' if you only want votes on certain nodes to be awarded with points.

And that was the last step already.
When voting the user gets points!

Cheat codes

There is a huge 'cheat' option in this system: your user can now vote multiple times on one node and get points for it every time.
I currently found no way to check if the user already voted on a certain node other than to add a user Flag that indicates if a certain user already voted on the node.
Doing it 'the Flag way' basically you set a flag that says 'this this user voted on this node'. Check before giving userpoints if that flag is set, and if so, don't give them the points. All throught Rules.

open issues that try to solve this:
Voting API http://drupal.org/node/1269614
Voting Rules http://drupal.org/node/981794

Rule Export

Here's the Rule I created for this tutorial. It applies to the standard Article content type.

{ "rules_user_votes_on_a_node" : {

    "LABEL" : "User votes on a node",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "userpoints_rules", "voting_rules" ],
    "ON" : [ "voting_rules_insert_node" ],
    "IF" : [
      { "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "article" : "article" } } } }
    ],
    "DO" : [
      { "userpoints_action_grant_points" : {
          "user" : [ "site:current-user" ],
          "points" : "10",
          "tid" : "0",
          "entity" : [ "" ],
          "description" : "Rewarded points for voting on an article",
          "operation" : "Insert",
          "display" : 1,
          "moderate" : "approved"
        }
      }
    ]
  }
}
Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Coder Cracker đã hạ gục 400 website thuộc Chính phủ Trung Quốc

Coder Cracker đã hạ gục 400 website thuộc Chính phủ Trung Quốc

Hacker mang bí danh “Coder Cracker” thuộc nhóm “Chiến binh ảo Pakistan” đã hạ gục 400 website thuộc Chính phủ Trung Quốc và khoe chiến tích lên mạng Pastebin.

Crack office

Hướng dẫn crack và download Office 2013 (office 15) Full Crack

Sau khi tải bộ cài đặt ở trên về, các bạn chọn phiên bản cần cài đặt rồi Mount file Iso ra setup bình thường. Cài đặt xong các bạn click vào file Start-KMSmicro-WO-En.vbs trong thư mục Activator để bắt đầu Crack

Facebook

Mỗi ngày Facebook xử lí hơn 500 TB dữ liệu

Jay Parikh, Phó Chủ tịch phụ trách cơ sở hạ tầng kĩ thuật của Facebook đã thống kê một danh sách cho thấy số dữ liệu khổng lồ mà bộ phận này này phải xử lí mỗi ngày.

Công ty diệt chuột T&C

 

Diet con trung