views:

10

answers:

1

I am trying to populate nodes by writing a script...i am using following code

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

whatsits doing is nothing and the term is not being added to vocabulary named tag...if i write the following code it will select the already existed term call xml..i guess because of 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);

i even tried the following code

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

can someone please help me how add terms into a already existed vocabulary

A: 

got it after reading hundreds of line code

$terms = new stdClass(); $terms->vid=1; $terms->name='success'; $get_tid=new stdClass();

taxonomy_term_save($terms);

term will be save in vocabulary vid=1 with automatic tid....

Zero Cool

related questions