【问题标题】:Node save with multiple taxonomy field of different vocabulary in drupal 6在drupal 6中使用不同词汇的多个分类字段保存节点
【发布时间】:2013-06-05 11:18:10
【问题描述】:

我正在尝试使用带有node_save 的php 创建一个节点。我在内容类型中有三个不同词汇的分类术语,所以我无法使用 php 创建内容类型的节点。 这是我的代码。

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");
}

请帮帮我

【问题讨论】:

    标签: drupal-6 taxonomy


    【解决方案1】:

    $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 )

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-20
      • 1970-01-01
      • 2014-05-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多