0

非公開で新しいノードを追加しようとしています。

ステータスを 0 に設定しました。

ただし、このノードをチェックすると、ステータス = 1;

このコード。

$node = new StdClass();
                $node->type = 'article'; //giving it type
                $node->title = $article->headline; //gives title
                $node->body = $article->body; //gives body

                $node->field_abstract[0]['value'] = $article->summary;
                $node->field_is_syndigate[0]['value'] = 1;
                $node->field_syndigate_first_time[0]['value'] = 1;

                $node->language = $language->language; //'en' or 'ar'
                $node->comment = 2; //read&write comment

                //$node->created = $article->parsed_at;
                $node->created = '';
                $node->changed = $node->created;
                $node->status = 0;
                $node->promote = 0;
                $node->sticky = 0;
                $node->format = 4; // Editor Filtered HTML
                $node->uid = $user->uid;

                //$node->field_attribution[0]['value'] = $article->copyright; // attribution
                $attribution = '';
                if($article->logo_path){
                    $attribution = '<img src="http://pub.syndigate.info/logos/small/'.$article->title_id.'.png" title="'.$article->title_name.'" border="0" />';
                    if($article->website){
                        $attribution = '<a href="'.$article->website.'" title="'.$article->title_name.'" target="_blank">'.$attribution.'</a>';
                    }
                    $attribution .= ' ';

                }
                $attribution .= $article->copyright;
                $node->field_attribution[0]['value'] = $attribution; // attribution
                $node->field_source[0]['value'] = $article->title_id; // source
                node_save($node);

ノードを非公開として保存する方法。

4

1 に答える 1

2

プログラムでノードを作成するときは、設定する必要があります

$node->is_new = TRUE; 

を空の値に設定している場合は$node->created、スクリプトからこの行を削除することをお勧めしますnode_save()。同じ$node->changed値を指定するのと同じです。スクリプトからこの行も削除するだけです

この助けを願っています

于 2012-04-30T15:06:40.793 に答える