function _taxonomy_menu_item in Taxonomy menu 6.2
Same name and namespace in other branches
- 7 taxonomy_menu.module \_taxonomy_menu_item()
Helper function for insert and update hooks
2 calls to _taxonomy_menu_item()
- taxonomy_menu_taxonomy_menu_insert in ./
taxonomy_menu.module - Implementation of hook_taxonomy_menu_insert().
- taxonomy_menu_taxonomy_menu_update in ./
taxonomy_menu.module - Implementation of hook_taxonomy_menu_update().
File
- ./
taxonomy_menu.module, line 792 - It Generates menu links for all selected taxonomy terms
Code
function _taxonomy_menu_item($item) {
// if tid is 0 then do not chagne any settings
if ($item['tid'] > 0) {
// get the number of node attached to this term
$num = _taxonomy_menu_term_count($item['tid']);
// if hide menu is selected and the term count is 0 and the term has no children then do not create the menu item
if ($num == 0 && variable_get('taxonomy_menu_hide_empty_terms_' . $item['vid'], FALSE) && !_taxonomy_menu_children_has_nodes($item['tid'], $item['vid'])) {
$item['remove'] = TRUE;
return $item;
}
// if display number is selected and $num > 0 then change the title
if (variable_get('taxonomy_menu_display_num_' . $item['vid'], FALSE)) {
// if number > 0 and display decendants, then count all of the children
if (variable_get('taxonomy_menu_display_descendants_' . $item['vid'], FALSE)) {
$num = taxonomy_term_count_nodes($item['tid']);
}
$item['name'] .= " ({$num})";
}
}
elseif ($item['tid'] == 0) {
// if custom name is provided, use that name
$custom_name = variable_get('taxonomy_menu_voc_name_' . $item['vid'], '');
if (!empty($custom_name)) {
$item['name'] = $custom_name;
}
}
return $item;
}