【问题标题】:How to create "draft" programmatically with Drupal Workbench Moderation?如何使用 Drupal Workbench Moderation 以编程方式创建“草稿”?
【发布时间】:2014-10-23 21:13:15
【问题描述】:

我创建了一个模块来自动编辑节点内容。该网站正在使用“Workbench Moderation”模块。

但我不知道如何让节点复制到新修订版中(处于“草稿”状态)。我编辑的内容始终出现在节点的“已发布”版本中。

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

【问题讨论】:

    标签: drupal-7 workbench


    【解决方案1】:

    我自己也遇到了这个问题。关键:

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

    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);
    

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

    【讨论】:

    • 非常感谢!我对 Workbench Moderation 负责修订的想法感到困惑。但我一直在寻找的正是$node-&gt;revision = 1;
    • 这也是吸引我的地方。 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-19
    • 2021-07-05
    • 2016-03-19
    • 2014-08-02
    • 1970-01-01
    • 2017-09-28
    相关资源
    最近更新 更多