function taxonomy_menu_block_get_taxonomy in Taxonomy menu block 7
Get taxonomy tree & name, taking into account i18n.
3 calls to taxonomy_menu_block_get_taxonomy()
- taxonomy_menu_block_build in ./
taxonomy_menu_block.module - Function to build our tree.
- taxonomy_menu_block_get_parents_fixed in ./
taxonomy_menu_block.admin.inc - Get parent tids.
- _taxonomy_menu_block_add_block_form_validate in ./
taxonomy_menu_block.admin.inc - Validate function.
File
- ./
taxonomy_menu_block.module, line 369 - Taxonomy Menu Block module allows you to make menu blocks out of your taxonomies in a very performant way.
Code
function taxonomy_menu_block_get_taxonomy($vid) {
if (module_exists('i18n_taxonomy')) {
global $language;
$lang = $language->language;
// Get cache. Format of cache id: module_name-vid-language.
$cache = cache_get('taxonomy_menu_block-' . $vid . '-' . $lang);
if ($cache) {
$taxonomy = $cache->data;
}
else {
$taxonomy = array();
$vocab = taxonomy_vocabulary_load($vid);
$taxonomy['name'] = i18n_taxonomy_vocabulary_name($vocab, $lang);
$tree = i18n_taxonomy_get_tree($vid, $lang);
// If data is empty, we have a vocabulary that is set to Translate or
// Fixed but none of the terms are actually translated
// (in the current language).
// Or the vacobulary is set to localize.
if (empty($tree)) {
$tree = i18n_taxonomy_localize_terms(i18n_taxonomy_get_tree($vid, 'und'));
}
$taxonomy['tree'] = taxonomy_menu_block_structure_tree($tree, $vid, $lang);
$cache = cache_set('taxonomy_menu_block-' . $vid . '-' . $lang, $taxonomy);
}
}
else {
$cache = cache_get('taxonomy_menu_block-' . $vid);
if (!$cache) {
$taxonomy = array();
$vocab = taxonomy_vocabulary_load($vid);
$taxonomy['name'] = $vocab->name;
$tree = taxonomy_get_tree($vid);
$taxonomy['tree'] = taxonomy_menu_block_structure_tree($tree, $vid);
$cache = cache_set('taxonomy_menu_block-' . $vid, $taxonomy);
}
else {
$taxonomy = $cache->data;
}
}
return $taxonomy;
}