gpt4 book ai didi

Drupal:以编程方式将工作台状态从草稿更改为已发布

转载 作者:行者123 更新时间:2023-12-01 09:56:27 26 4
gpt4 key购买 nike

我想进行批量操作并将节点从草稿状态更改为已发布。我根据之前的更改创建了一个新修订版,但所有修订版都默认为草稿。现在我想基本上只发布新的修订版。 (我正在使用 Workbench 模块。)

我试过做下面的事情,但似乎都不起作用:

$node->workbench_moderation['current']->published = "1";

$node->workbench_moderation['current']->from_state = "draft";
$node->workbench_moderation['current']->state = "published";
$node->workbench_moderation['current']->published = "1";

$node->workbench_moderation['published']->from_state = "draft";
$node->workbench_moderation['published']->state = "published";
$node->workbench_moderation['published']->published = "1";

$node->workbench_moderation['my_revision']->from_state = "draft";
$node->workbench_moderation['my_revision']->state = "published";
$node->workbench_moderation['my_revision']->published = "1";
$node->workbench_moderation['my_revision']->current = TRUE;

workbench_moderation_moderate($node, 'published');

我也试过使用下面的而不是 node_save 来保存,我想也许 node_save 触发了一个新的草稿。

workbench_moderation_node_update($node);

我只想简单地加载节点,发布草稿,然后再次保存。

知道我做错了什么吗?

最佳答案

workbench_moderation_moderate 是正确的,我会这样做来批量发布一些节点:

$nodes = node_load_multiple($nodes);
foreach ($nodes as $node) {
$node->status = 1;
node_save($node);
workbench_moderation_moderate($node, 'published');
}

关于Drupal:以编程方式将工作台状态从草稿更改为已发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25798249/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com