function tft_add_term in Taxonomy File Tree 7.2
Add a new term and return its ID.
Parameters
string $name:
int $parent:
Return value
int
Related topics
3 calls to tft_add_term()
- tft_add_term_form_submit in includes/
tft.pages.inc - Submission callback: for tft_add_term_form().
- tft_archive_create_archive_folder in modules/
tft_archive/ tft_archive.module - Creates an archive folder under the passed folder.
- tft_archive_folder_batch_process in ./
tft.module
File
- ./
tft.module, line 1127 - Hook implementations and module logic for TFT.
Code
function tft_add_term($name, $parent) {
// Add the term data
$tid = db_insert('taxonomy_term_data')
->fields(array(
'tid' => NULL,
'vid' => variable_get('tft_vocabulary_vid', 0),
'name' => $name,
'description' => '',
'weight' => 0,
))
->execute();
if (empty($parent)) {
$parent = 0;
}
// Add the term hierarchy
db_insert('taxonomy_term_hierarchy')
->fields(array(
'tid' => $tid,
'parent' => $parent,
))
->execute();
return $tid;
}