0

我正在尝试通过编写脚本来填充节点...我正在使用以下代码

$node->field_tags['und'][0]['textfield'] = 'first_tag';
$node->field_tags['und'][0]['textarea'] = 'This is tag';
$node->field_tags['und'][0]['tid'] = 2;
node_save($node);

什么都没有,并且该术语没有被添加到名为标签的词汇表中...如果我编写以下代码,它将选择已经存在的术语调用 xml ..我猜是因为 tid=1;

$node->field_tags['und'][0]['textfield'] = 'first_tag';
$node->field_tags['und'][0]['textarea'] = 'This is tag';
$node->field_tags['und'][0]['tid'] = 2;
node_save($node);

我什至尝试了以下代码

$node->field_tags['und'][0]['name'] = 'first_tag';
$node->field_tags['und'][0]['description'] = 'This is tag';
$node->field_tags['und'][0]['tid'] = 2;
node_save($node);

有人可以帮我如何将术语添加到已经存在的词汇表中

4

2 回答 2

1

使用以下函数动态获取视频

$vid = taxonomy_vocabulary_machine_name_load('vocabname');
$terms = new stdClass();
$terms->vid = $vid; 
$terms->name='whatever name of your term'; 
taxonomy_term_save($terms);

谢谢, 安库什

于 2017-07-21T10:04:28.070 回答
0

阅读数百行代码后得到它

$terms = 新的 stdClass(); $terms->vid=1; $terms->name='成功'; $get_tid=新标准类();

taxonomy_term_save($terms);

术语将保存在词汇表 vid=1 中,并带有自动 tid....

于 2010-08-27T16:09:50.590 回答