function taxonomy_menu_nodeapi in Taxonomy menu 6
Same name and namespace in other branches
- 5 taxonomy_menu.module \taxonomy_menu_nodeapi()
- 6.2 taxonomy_menu.module \taxonomy_menu_nodeapi()
Implementation of hook_nodeapi().
This hook enables the menu to be displayed in context during node views.
File
- ./
taxonomy_menu.module, line 31 - @author Jonathan Chaffer <jchaffer@structureinteractive.com> @author Bruno Massa <http://drupal.org/user/67164> taxonomy_menu.module It Generates menu links for all taxonomy terms
Code
function taxonomy_menu_nodeapi(&$node, $op, $a3, $a4) {
static $vocabs = array();
// First check if the node has a relevant category.s
if (empty($vocabs) and is_array($vocabs)) {
$terms = taxonomy_node_get_terms($node);
// The node should have taxonomy terms
if (empty($terms)) {
return;
}
// Check if at least one vocabulary is revelevant
// for us, being a menu
foreach ($terms as $term) {
if (variable_get('taxonomy_menu_show_' . $term->vid, TAXONOMY_MENU_NONE)) {
$vocabs[$term->vid][] = $term->tid;
}
}
// If none of the terms are tracked by this module,
// forget it
if (empty($vocabs)) {
$vocabs = FALSE;
return;
}
}
if ($op == 'view' and $a4 == TRUE and !empty($vocabs)) {
require_once drupal_get_path('module', 'taxonomy_menu') . '/taxonomy_menu.inc';
_taxonomy_menu_node_view($node, $vocabs);
}
elseif ($op == 'update' or $op == 'insert' or $op == 'delete') {
variable_set('menu_rebuild_needed', TRUE);
}
}