function ip_geoloc_get_tid_from_name in IP Geolocation Views & Maps 7
Utility function to convert a term name to its associated taxonomy term id.
Parameters
string $term_name: e.g., 'Amsterdam'
string $vocabulary_machine_name: (optional) e.g., 'city' or simply omit, if known to be unique
Return value
int|string The term id if found, FALSE otherwise.
1 call to ip_geoloc_get_tid_from_name()
- _ip_geoloc_plugin_style_match_on_taxonomy_term_or_parent in views/
ip_geoloc_plugin_style.inc - Find a color association record for the suppplied taxonomy term id or name.
File
- views/
ip_geoloc_plugin_style.inc, line 1513 - ip_geoloc_plugin_style.inc
Code
function ip_geoloc_get_tid_from_name($term_name, $vocabulary_machine_name = NULL) {
foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
if (empty($vocabulary_machine_name) || $vocabulary_machine_name == $vocabulary->machine_name) {
foreach (taxonomy_get_tree($vid) as $term) {
if ($term_name == $term->name) {
return $term->tid;
}
}
}
}
return FALSE;
}