function _get_term_from_name in Event Calendar 7
Helper function to dynamically get the tid from the term_name
Parameters
string $term_name: Term name data.
string $vocabulary_name: Name of the vocabulary to search the term in it.
Return value
string Term id Term ID of the found term or else FALSE.
1 call to _get_term_from_name()
- _event_calendar_installed_instances in ./
event_calendar.install - Callback to define instances of fields.
File
- ./
event_calendar.install, line 334 - install file for Event Calendar module.
Code
function _get_term_from_name($term_name, $vocabulary_name) {
if ($vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_name)) {
$tree = taxonomy_get_tree($vocabulary->vid);
foreach ($tree as $term) {
if ($term->name == $term_name) {
return $term->tid;
}
}
}
return NULL;
}