function user_badges_get_term_from_vid in User Badges 7.3
Same name and namespace in other branches
- 7 user_badges.admin.inc \user_badges_get_term_from_vid()
- 7.2 user_badges.admin.inc \user_badges_get_term_from_vid()
Get terms belonging to a vocabulary. Can be used in the form's #options field.
Parameters
vid: The vocabulary's id.
Return value
Array whose key is the tid and value the term's name.
1 call to user_badges_get_term_from_vid()
- user_badges_edit_form in ./
user_badges.admin.inc - Define the edit form for userbadges.
File
- ./
user_badges.admin.inc, line 1082 - @brief User Badges admin functions
Code
function user_badges_get_term_from_vid($vid) {
$query = db_select('taxonomy_term_data', 't');
$query
->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
$query
->fields('t', array(
'tid',
'name',
));
$query
->condition('t.vid', $vid, '=');
$query
->condition('h.parent', 0, '=');
// remove this line to get all terms.
$result = $query
->execute();
$data = array();
while ($record = $result
->fetchAssoc()) {
$data[$record['tid']] = t($record['name']);
}
return $data;
}