drupal functions → Функции модуля Taxonomy 7.x
Получить объект термина по tid
$term = taxonomy_term_load($tid);
Получить дерево словаря
taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $load_entities = FALSE)
$vid Which vocabulary to generate the tree for.
$parent The term ID under which to generate the tree. If 0, generate the tree for the entire vocabulary.
$max_depth The number of levels of the tree to return. Leave NULL to return all levels.
$load_entities If TRUE, a full entity load will occur on the term objects. Otherwise they are partial objects queried directly from the {taxonomy_term_data} table to save execution time and memory consumption when listing large numbers of terms. Defaults to FALSE.
Получить массив словарей с индексом по vid
taxonomy_get_vocabularies()
**Получить массив терминов по имени **
taxonomy_get_term_by_name($name)
Получить массив детей термина
taxonomy_get_children($tid, $vid = 0)
Получить массив родителей термина
taxonomy_get_parents($tid)
**Сохранить термин **
taxonomy_term_save($term)
$term The taxonomy term object with the following properties:
- vid: The ID of the vocabulary the term is assigned to. name: The name of the term.*
- tid: (optional) The unique ID for the term being saved. If $term->tid is empty or omitted, a new term will be inserted. description: (optional) The term’s description.*
- format: (optional) The text format for the term’s description.*
- weight: (optional) The weight of this term in relation to other terms within the same vocabulary.*
- parent: (optional) The parent term(s) for this term. This can be a single term ID or an array of term IDs. A value of 0 means this term does not have any parents. When omitting this variable during an update, the existing hierarchy for the term remains unchanged.*
- vocabulary_machine_name: (optional) The machine name of the vocabulary the term is assigned to. If not given, this value will be set automatically by loading the vocabulary based on $term->vid.*
- original: (optional) The original taxonomy term object before any changes were applied. When omitted, the unchanged taxonomy term object is loaded from the database and stored in this property.*