用户工具

站点工具


drupal:script:save_node

添加/新建 Drupal节点

<?php
    chdir('your drupal location');
    require_once './includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
 
    $node = new StdClass();
    $node->type = 'news';  // *** This needs to be a valid content type
    $node->uid = 1;
    $node->status = 1;  //0: unpublish; 1: publish
    $node->promote = 1;  //promote to frontpage
    $node->sticky = 0;  //sticky at top
    $node->format = FILTER_FORMAT_DEFAULT;  //FILTER_FORMAT_DEFAULT	
                                        //FILTER_HTML_ESCAPE	
                                        //FILTER_HTML_STRIP	
    $node->field_newsrc = array( 0 => array("value"=>$item[$LINK_INDEX]));
    $node->title = "title";
    $node->body = "body";
    $node->teaser = "teaser";
 
    $tname = "test";
    $node->taxonomy["tags"][1] = $tname;
    $node->taxonomy[4] = array ( 0 => "1" );
    $node->taxonomy[2] = array ( 0 => "177" );
 
    node_save($node);
drupal/script/save_node.txt · 最后更改: 2010/12/02 07:07 (外部编辑)