如何使用Drupal Workbench Moderation以编程方式创建"草稿"?

Dou*_*oma 6 drupal-7 workbench

我已经创建了一个模块来自动编辑节点内容.该网站正在使用"Workbench Moderation"模块.

但我无法弄清楚如何将节点复制到新版本(处于"草稿"状态).我编辑的内容始终显示在节点的"已发布"版本中.

有谁知道API调用应该是什么来实现这一目标?

Gol*_*old 7

我自己就是这个问题.关键事项:

  • 内容类型通过工作台审核模块进行审核
  • 设置新的审核状态
  • 将节点设置为新修订

Drupal负责其余的工作.

<?php
$node = node_load($nid);
$node->body[LANGUAGE_NONE][0]['value'] = 'My new body content';
// We're wanting drupal to create a new revision
$node->revision = 1;
// We want workbench moderation to treat the new revision as a new draft
$node->workbench_moderation_state_new = workbench_moderation_state_none();
node_save($node);
Run Code Online (Sandbox Code Playgroud)

这目前在我的代码库中工作.