如何为特定内容类型创建/更新 drupal 6 CCK 组字段
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
曾一度使用类似的方法从其他数据库获取和重新格式化数据并将其插入到 Drupal 中:
在您的特定情况下需要进行一些修改,但应该给您一些开始的机会。
Been using something like this at one point to fetch and reformat data from other database and insert it into Drupal's:
Would need few amends to use in your specific case, but should give you something to start with.