继续Drupal分享精神 QQ群:107748121 站长QQ:532116351【drupal交流+drupal 建站+theme制作】
登录 注册

Drupal 外部数据提交保存 node_save,以及cck字段

数据保存到数据,可以使用node_save来操作。

<?php

   $edit
= array();//定义一个数组
  
$edit['type'] = $mycontenttype;//内容类型
  
$edit['uid'] = 0;//匿名用户
  
$node_type_default = variable_get('node_options_'. $edit['type'], array('status', 'promote'));
  
$edit['promote'] =1;
  
$edit['comment'] =2;
  
$edit['revision'] = in_array('revision', $node_type_default);
  
$edit['format'] = FILTER_FORMAT_DEFAULT;
  
$edit['status'] = 1;
  
$edit['title'] = $title;//标题
  
$edit['taxonomy']['tags']=$getterms;//
  
$edit['body'] = $description;//body 正文部分
  
$edit['employer'] = $employer;// 额外字段,我这里是自己的数据库字段
//××××××××××××××××
//如果是cck字段 这样处理:
$edit['field_字段名称'][0]['value'] = $_POST['getname'];
//×××××××××××××××
  
$edit['date'] = format_date(time(), 'custom', 'Y-m-d H:i:s O');
 
//  node_invoke_nodeapi($edit, $type);
  
node_validate($edit);
  
$node = node_submit($edit);
  
node_save($node);
?>

评论

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 自动断行和分段。
  • You can use BBCode tags in the text.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.