Creating a new taxonomy term dynamically using PHP

goron - September 6, 2009 - 02:35

Hi,

I'm trying to write a script that saves a new taxonomy term. How should I do this? taxonomy_save_term? taxonomy_term_submit?

thanks.

check out these modules

arhak - September 6, 2009 - 02:49

check out these modules:
taxonomy_csv - function taxonomy_csv_import_line
install_profile_api - function install_taxonomy_add_term

both of them use taxonomy_save_term

Yes, that helped. Thanks.

goron - September 6, 2009 - 16:15

Yes, that helped. Thanks.

Sample Code

suro.solutions - September 6, 2009 - 16:29

Here is the sample code you can use

$new_term_cat = array();
$new_term_cat['name'] =  'category name';
$new_term_cat['vid'] = $vid;   / / vocab id
$new_term_cat['parent'] = 0;
$new_term_cat['weight'] = 0;
taxonomy_save_term($new_term_cat);

Thanks,

Suro
http://www.drupalextras.com/

Thanks both of you that

goron - September 19, 2009 - 18:17

Thanks both of you that worked.

 
 

Drupal is a registered trademark of Dries Buytaert.