function _taxonomy_menu_nodeapi_helper in Taxonomy menu 7
Same name and namespace in other branches
- 8 taxonomy_menu.module \_taxonomy_menu_nodeapi_helper()
- 6.2 taxonomy_menu.module \_taxonomy_menu_nodeapi_helper()
- 7.2 taxonomy_menu.module \_taxonomy_menu_nodeapi_helper()
Builds argument arrays calls taxonomy_menu_handler.
Parameters
string $op: The operation to be performed [update|insert|delete]
array $terms: The taxonomy terms.
$node: The node object.
3 calls to _taxonomy_menu_nodeapi_helper()
- taxonomy_menu_node_delete in ./
taxonomy_menu.module - Implements hook_node_delete().
- taxonomy_menu_node_insert in ./
taxonomy_menu.module - Implements hook_node_insert().
- taxonomy_menu_node_update in ./
taxonomy_menu.module - Implements hook_node_update().
File
- ./
taxonomy_menu.module, line 521 - Adds links to taxonomy terms into a menu.
Code
function _taxonomy_menu_nodeapi_helper($op, $terms = array(), $node) {
foreach ($terms as $key => $tid) {
// If taxonomy $term is false, then go to the next $term.
// taxonomy_term_load($tid) returns FALSE if the term was not found.
if (!($term = taxonomy_term_load($tid))) {
continue;
}
// Update the menu for each term if necessary.
$menu_name = variable_get(_taxonomy_menu_build_variable('vocab_menu', $term->vid), FALSE);
$vocb_sync = variable_get(_taxonomy_menu_build_variable('sync', $term->vid), TRUE);
$menu_num = variable_get(_taxonomy_menu_build_variable('display_num', $term->vid), TRUE);
$menu_num_inc_children = variable_get(_taxonomy_menu_build_variable('display_num_incl_children', $term->vid), TRUE);
$hide_empty = variable_get(_taxonomy_menu_build_variable('hide_empty_terms', $term->vid), FALSE);
if ($menu_name && $vocb_sync && ($menu_num || $hide_empty)) {
// Build argument array to save menu_item.
$args = array(
'tid' => $term->tid,
'vid' => $term->vid,
'term' => $term,
'menu_name' => $menu_name,
'mlid' => _taxonomy_menu_get_mlid($term->tid, $term->vid),
);
if ($op == 'delete') {
/* Turn the op to 'update' here since we really do want to update the item
* and not delete/recreate it, since the latter will break hierarchy and
* customizations.
*/
$op = 'update';
}
taxonomy_menu_handler($op, $args, $node);
if ($hide_empty || $menu_num && $menu_num_inc_children) {
_taxonomy_menu_update_all_parents($term, $menu_name);
}
}
}
}