如何为特定内容类型创建/更新 drupal 6 CCK 组字段

发布于 2024-11-17 04:12:50 字数 924 浏览 2 评论 0原文

我在 Drupal 6 中进行了以下设置:

节点内容类型:uprofile

字段: 字段组:带有字段 field_about_me、field_programinfo 的 group_about

我正在使用以下逻辑创建一个节点:

$node = new stdClass();
$node->title = trim($name);
$node->type = 'uprofile';
$node->created = time();
node_save($node);

是我尝试的一种方法(来自 drupal 站点):

$form_state = array();
module_load_include('inc', 'node', 'node.pages');
$form_state['values']['type'] = 'uprofile';
$form_state['values']['status'] = 1;
$form_state['values']['op'] = t('Save');
$nodetype = array('type' => 'uprofile');
$form_state['values']['title'] = trim($name);
form_state['values']['field_about_me'][0]['value'] = trim($name);
$form_state['values']['field_programinfo'][0]['value'] = trim($name);
drupal_execute('uprofile_node_form', $form_state, (object)$nodetype);

我尝试使用各种方法保存节点,但所有方法都是徒劳的,这 没有效果,我对此没有想法。谁能指导我正确的方向。

谢谢。

I have following setup in Drupal 6:

Node Content Type: uprofile

Fields:
field group: group_about with fields field_about_me, field_programinfo

I am creating a node using the following logic:

$node = new stdClass();
$node->title = trim($name);
$node->type = 'uprofile';
$node->created = time();
node_save($node);

I tried to save node using various methods, but all of them were futile, here is the one way I tried this(from drupal site):

$form_state = array();
module_load_include('inc', 'node', 'node.pages');
$form_state['values']['type'] = 'uprofile';
$form_state['values']['status'] = 1;
$form_state['values']['op'] = t('Save');
$nodetype = array('type' => 'uprofile');
$form_state['values']['title'] = trim($name);
form_state['values']['field_about_me'][0]['value'] = trim($name);
$form_state['values']['field_programinfo'][0]['value'] = trim($name);
drupal_execute('uprofile_node_form', $form_state, (object)$nodetype);

This had no effect, and I am out of ideas on this. Can anyone please guide me in the right direction.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖树树初阳… 2024-11-24 04:12:50

曾一度使用类似的方法从其他数据库获取和重新格式化数据并将其插入到 Drupal 中:

$node = new StdClass();
$node->type = 'NODETYPE';
$node->status = 1;
$node->format = 2;
$node->moderate = 0;
$node->promote = 0;
$node->sticky = 0;
$node->revision = 0;
$node->comment = 0;
// Main node content
$node->title = 'TITLE';
$node->teaser = '';
$node->body = 'BODY';
// Author details
$node->uid = 1;
$node->name = 'USERNAME';
// CCK fields
$node->field_NODETYPE_summary[0]['value'] = 'SUMMARY';
$node->field_NODETYPE_details[0]['value'] = 'DETAILS';
// Submit and save
$node = node_submit($node);
node_save($node);

在您的特定情况下需要进行一些修改,但应该给您一些开始的机会。

Been using something like this at one point to fetch and reformat data from other database and insert it into Drupal's:

$node = new StdClass();
$node->type = 'NODETYPE';
$node->status = 1;
$node->format = 2;
$node->moderate = 0;
$node->promote = 0;
$node->sticky = 0;
$node->revision = 0;
$node->comment = 0;
// Main node content
$node->title = 'TITLE';
$node->teaser = '';
$node->body = 'BODY';
// Author details
$node->uid = 1;
$node->name = 'USERNAME';
// CCK fields
$node->field_NODETYPE_summary[0]['value'] = 'SUMMARY';
$node->field_NODETYPE_details[0]['value'] = 'DETAILS';
// Submit and save
$node = node_submit($node);
node_save($node);

Would need few amends to use in your specific case, but should give you something to start with.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文