我正在使用自定义模块创建节点
$node = new stdClass();
$node->type = $link['content_type'];
node_object_prepare($node);
$node->uid = $user->uid;
$node->name = $user->name;
$node->title = $html['title'];
$node->language = LANGUAGE_NONE;
$node->body[$node->language][0]['value'] = $html['html'];
$node->body[$node->language][0]['summary'] = $html['summary'];
$node->body[$node->language][0]['format'] = 'filtered_html';
$node->menu['enabled'] = 0; // 1 to enable providing a link in main menu
$node->menu['link_title'] = urlencode($html['title']);
$node->menu['description'] = urlencode($html['summary']);
$node->menu['parent'] = 'main-menu:0';
$node->menu['weight'] = 5;
$node->path['alias'] = urlencode($html['title']) . time();
$node->comment = 1;
$node->status = 1; // 1 means published
$node->promote = 0;
$node->revision = 0;
$node->changed = $_SERVER['REQUEST_TIME'];
$node->created = $_SERVER['REQUEST_TIME'];
node_submit($node);
@node_save($node);
$node->path['alias'] .= '+' . $node->nid;
node_submit($node);
@node_save($node);
db_update('node_revision')
->fields(array('uid' => $node->uid))
->condition('vid', $node->vid)
->execute();
但是现在我需要为每个节点分配一个我创建的工作台部分,所以我尝试这样做:
$node->workbench_access = array('66');
node_submit($node);
@node_save($node);
$node->path['alias'] .= '+' . $node->nid;
node_submit($node);
@node_save($node);
db_update('node_revision')
->fields(array('uid' => $node->uid))
->condition('vid', $node->vid)
->execute();
这会临时添加工作台访问 ID,但刷新页面时不会应用它。有没有办法使用 php 将节点分配给工作台部分?