function taxonomy_menu_nodeapi in Taxonomy menu 5
Same name and namespace in other branches
- 6 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 88 - taxonomy_menu.module @author Jonathan Chaffer <jchaffer@structureinteractive.com> @author Bruno Massa <http://drupal.org/user/67164> It Generates menu links for all taxonomy terms
Code
function taxonomy_menu_nodeapi(&$node, $op, $a3, $a4) {
static $vocabs = array();
// skip checking for vocabs if display node context is disabled
if (!variable_get('taxonomy_menu_display_context', TRUE)) {
$vocabs = NULL;
}
// First check if the node has a relevant category.s
if (empty($vocabs) and is_array($vocabs)) {
// The node should have taxonomy terms
if (!($terms = taxonomy_node_get_terms($node->nid))) {
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') {
variable_set('menu_rebuild_needed', TRUE);
}
}