【问题标题】:Drupal 7 - Fivestar and UserpointsDrupal 7 - Fivestar 和用户点
【发布时间】:2014-03-24 22:13:30
【问题描述】:

我有一个内容类型以及登录用户对其进行投票的可能性。节点上有 5 个不同的五星级投票(类别)。现在我想添加用户点,并想问是否有可能当用户投票时,他在节点上的每一次投票都会得到 1 分,如果他在每个类别中投票,就可以得到 5 分。他有可能稍后改变投票,但他不应该再得到任何分数。这可能吗?

问候

【问题讨论】:

    标签: drupal drupal-7 userpoints fivestar


    【解决方案1】:

    虽然看起来没有实现此目标的现有 7.x 或 8.x 模块,但您应该可以通过两种方式实现目标:

    • 编写一个模块。Userpoints API is fairly well-documented 并且应该可以创建一个模块来在修改五星级字段时增加用户的用户点计数。为避免重复,请注意该字段看起来应该完成您正在寻找的重复数据删除(假设您将 txn_id 设置为当前节点 ID、字段 ID 和用户 ID 的某种组合:

    'txn_id' => (int) Transaction ID of a current points record. If present an UPDATE occurs

    • 使用规则。 用户点模块与规则集成,因此您应该能够在不编写任何代码的情况下完成用户点用例。根据Userpoints Rules integration notes,您可以将当前用户点数与交易前的点数进行比较:

    Compare Userpoints before the transaction - This condition is used to compare the amount of userpoints the user had before the userpoints was added to/deducted from the user against a specified value. - The 'Amount to compare' value is checked as >= (greater than or equal to) and the Negate checkbox will change the condition to < (less than) as it will be any value other than >=. If you would like to get an exact value, say 1, you can add two of the condition to use >= and < to specify one number. Simple math stuff here =)

    我希望这会有所帮助。告诉我进展如何!

    【讨论】:

    • 你好,谢谢你的回答,我的PHP知识很少,所以我会尝试用Rules来做。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-06
    • 2014-07-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多