function _taxonomy_menu_create_item in Taxonomy menu 6.2
Same name and namespace in other branches
- 7 taxonomy_menu.module \_taxonomy_menu_create_item()
Create the inital $item array
Parameters
$args: array with the following key/value pairs: 'term' => term object, if updating a term 'menu_name' => menu that the item is set to apply to 'vid' => vocab id. if editing vocab item 'mlid' => menu id
$item: array with the following key/value pairs: 'tid' => the term id (if 0 then updating the vocab as an item) 'name' => new menu name 'description' => new menu description, used as to build the title attribute 'weight' => new menu weight 'vid' => the new vocabulary's id 'ptid' => the new parent tid 'mlid' => mlid that needs to be edited 'path_type' => either term, tid or vid.
- This is what will be pased to the path function
- This must be a key of the array also.
1 call to _taxonomy_menu_create_item()
- taxonomy_menu_handler in ./
taxonomy_menu.module - HANDLING
File
- ./
taxonomy_menu.module, line 713 - It Generates menu links for all selected taxonomy terms
Code
function _taxonomy_menu_create_item($args = array()) {
// if tid = 0 then we are creating a vocab item
if ($args['tid'] == 0 && variable_get('taxonomy_menu_voc_item_' . $args['vid'], 0)) {
$vocab = taxonomy_vocabulary_load($args['vid']);
$item = array(
'tid' => 0,
'name' => $vocab->name,
'description' => $vocab->description,
'weight' => $vocab->weight,
'vid' => $args['vid'],
'ptid' => 0,
'menu_name' => $args['menu_name'],
'language' => $vocab->language,
);
return $item;
}
else {
$term = $args['term'];
}
// get the first parent
if (is_array($term->parents)) {
foreach ($term->parents as $key => $val) {
$ptid = $val;
break;
}
}
else {
$ptid = $term->parents;
}
// if ptid is empty, then set it to 0
if (empty($ptid)) {
$ptid = 0;
}
// turn the term into the correct $item array form
$item = array(
'tid' => $term->tid,
'name' => $term->name,
'description' => $term->description,
'weight' => $term->weight,
'vid' => $term->vid,
'ptid' => $ptid,
'menu_name' => $args['menu_name'],
'language' => $term->language,
);
if ($args['mlid']) {
$item['mlid'] = $args['mlid'];
}
return $item;
}