Drupal的创建投票API中投票通过code [英] Drupal Creating Votes in Voting API Through Code

查看:211
本文介绍了Drupal的创建投票API中投票通过code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义模块我写,一部分的我想要它做的是创建一个节点相关联的票,我想弄清楚如何从我的模块调用API投票。我loookd文档中,但它是一个有点稀疏。

I have a custom module I'm writing, part of what I want it to do is create a vote associated with a node, I'm trying to figure out how to call the voting API from my module. I loookd in the documentation but it's a little sparse.

推荐答案

下面是一个模块,我写了前段时间的例子。

Here is an example from a module I wrote a while ago.

while ($data = db_fetch_object($result)) {
  $node = node_load($data->nid);
  $node_terms = taxonomy_node_get_terms($node);
  $vote['value'] = 0;
  $vote['value_type'] = 'points';
  foreach ($node_terms as $term) {
    $vote['value'] = $vote['value'] + $users_tags[$term->name];
  }
  $vote['content_id'] = $node->nid;
  if (isset($vote['content_id'])) {
    votingapi_set_votes($vote);
  }
}

这篇关于Drupal的创建投票API中投票通过code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆