开发者

How to create/update drupal 6 CCK group fields for a specific content type

开发者 https://www.devze.com 2023-03-15 09:05 出处:网络
I have following setup in Drupal 6: Node Content Type: uprofile Fields: field group: group_about with fields field_about_me, field_programinfo

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 = ar开发者_JAVA百科ray();
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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号