我想做一个大容量操作,并将节点从草案状态更改为已发布的节点。我根据以前的更改创建了一个新的修订版,但是所有的修订都默认为草案。现在,我想基本上只是发表新的修订本。(我正在使用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);我只想简单地加载节点,发布草案,然后再保存它。
知道我做错了什么吗?
发布于 2014-09-12 03:49:41
workbench_moderation_moderate是正确的,我会这样做来批量发布一些节点:
$nodes = node_load_multiple($nodes);
foreach ($nodes as $node) {
$node->status = 1;
node_save($node);
workbench_moderation_moderate($node, 'published');
}发布于 2014-09-12 14:42:41
除了@klidifia所说的话外,我还想提出另一个对我有用的解决方案。
$nid = 1234;
$node = node_load($nid);
$node->body['und'][0]['value'] = 'new body';
$node->workbench_moderation_state_new = workbench_moderation_state_published();
$node->revision = 1;
$node->log = 'State Changed to published';
node_save($node);我之所以接受klidifia的回答,是因为我的解决方案显示了当前修订版上的消息From Published --> Published on...,而上面的解决方案实际上显示了一个更符合逻辑的工作流:
From Draft --> Published on...
From Published --> Draft on...https://stackoverflow.com/questions/25798249
复制相似问题