Thursday, January 19, 2012

Using taxonomy_get_tree,taxonomy_get_children in Drupal

Using taxonomy_get_tree in Drupal;

@param $vid
 *   Which vocabulary to generate the tree for.
 *
 * @param $parent
 *   The term ID under which to generate the tree. If 0, generate the tree
 *   for the entire vocabulary.
 *
 * @param $depth
 *   Internal use only.
 *
 * @param $max_depth
 *   The number of levels of the tree to return. Leave NULL to return all levels.
 *
 * @return
 *   An array of all term objects in the tree. Each term object is extended
 *   to have "depth" and "parents" attributes in addition to its normal ones.
 *   Results are statically cached.
$taxo =taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL);
$name = $taxo[0]->name;
$tid = $taxo[0]->tid;
$description= $taxo[0]->description;

@param $tid
 *   $tid is from taxonomy_get_tree.
 *   $tid is the parent id
$taxo_child = taxonomy_get_children($tid, $vid = 0, $key = 'tid')

No comments:

Post a Comment