2013-06-05 44 views
0

我試圖用node_save與PHP創建一個節點。我在內容類型中有三個不同詞彙的分類術語字段,所以我無法使用php創建內容類型的節點。 這是我的代碼。節點保存與多個分類學領域的不同詞彙在Drupal 6

global $user; 
$tid = 3; //Different vocabulary 
$tid1 = 66;//Different vocabulary 
$tid2 = 940;//Different vocabulary 
$term_id = 1265; //Different vocabulary 
$node = new StdClass(); 
$node->title = 'Tips 4 Life'; 
$node->type = 'tips_for_life'; 
$node->body = 'test'; 
$node->field_tip_text['0']['value'] = $value['value']; 
$node->status = 1; 
$node->format = 1; 
$node->moderate = 0; 
$node->promote = 0; 
$node->sticky = 0; 
$node->revision = 0; 
$node->name = $user->name; 
$node->comment = 0; 

$node->taxonomy = array($tid => $tid ,$term_id => $term_id,$tid1 => $tid1,$tid2 => $tid2); 

$node = node_submit($node); 
$done = node_save($node); 
if($done) 
{ 
drupal_set_message("done"); 
} 
else { 
drupal_set_message("Not done"); 
} 

請幫我

回答

0

$node->taxonomy被存儲在以下方式:

[taxonomy] => Array 
    (
     [2] => stdClass Object 

      (
       [tid] => 2 
       [vid] => 2 
       [name] => Descrip 1 
       [description] => 
       [weight] => 0 
      ) 

     [1] => stdClass Object 
      (
       [tid] => 1 
       [vid] => 4 
       [name] => Descrip 2 
       [description] => 
       [weight] => 0 
      ) 

    ) 

你有沒有試過如下:

$node->taxonomy[] = array(etc etc etc)