taxonomy_menu_trails.module in Taxonomy Menu Trails 6
Same filename and directory in other branches
Changes menu trail of current node to its lightest term's menu item (only if node doesn't belong to any menu)
@author Dmitriy.trt <http://drupal.org/user/329125>
File
taxonomy_menu_trails.moduleView source
<?php
/**
* @file
* Changes menu trail of current node to its lightest term's
* menu item (only if node doesn't belong to any menu)
*
* @author Dmitriy.trt <http://drupal.org/user/329125>
*/
/**
* Implementation of hook_init().
*/
function taxonomy_menu_trails_init() {
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
}
else {
$exprs = variable_get('taxonomy_menu_trails_node_paths', array());
$match = FALSE;
foreach ($exprs as $kind => $patterns) {
foreach ($patterns as $pattern) {
if (preg_match($pattern, $_GET['q'], $m)) {
$node = node_load(array(
$kind => $m[1],
));
$match = TRUE;
break 2;
}
}
}
if (!$match) {
return;
}
}
$enabled_types = variable_get('taxonomy_menu_trails_node_types', array());
$item = menu_get_item();
if (!empty($node->taxonomy) && !empty($enabled_types[$node->type]) && (!variable_get('taxonomy_menu_trails_only_without_menu', TRUE) || db_result(db_query('SELECT mlid FROM {menu_links} WHERE link_path = "%s" AND hidden = 0 LIMIT 1', $item['href'])) == 0)) {
module_load_include('inc', 'taxonomy_menu_trails');
_taxonomy_menu_trails_process($node, $item);
}
}
/**
* Implementation of hook_menu().
*/
function taxonomy_menu_trails_menu() {
$items = array(
'admin/settings/taxonomy-menu-trails' => array(
'title' => 'Taxonomy menu trails',
'description' => 'Settings for taxonomy-based active trail on the node page.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'taxonomy_menu_trails_settings',
),
'access arguments' => array(
'administer taxonomy menu trails',
),
'type' => MENU_NORMAL_ITEM,
'file' => 'taxonomy_menu_trails.admin.inc',
),
);
return $items;
}
/**
* Implementation of hook_perm().
*/
function taxonomy_menu_trails_perm() {
return array(
'administer taxonomy menu trails',
);
}
Functions
Name | Description |
---|---|
taxonomy_menu_trails_init | Implementation of hook_init(). |
taxonomy_menu_trails_menu | Implementation of hook_menu(). |
taxonomy_menu_trails_perm | Implementation of hook_perm(). |