显示到内容页面可以先利用pathauto定制路径,利用路径的不同来筛选block的显示。
我定制的路径为
v/[term:vocabulary:vid]/t/[term:tid]
v/[node:field-service-fenlei:vocabulary:vid]/t/[node:field-service-fenlei:tid]/[node:nid]
在block中添加v/8/*,筛选出来即可
function my_module_superfish_active_trail_alter(&$trail){}
function bootstrap_subtheme_superfish_active_trail_alter(&$trail){}
function my_module_superfish_active_trail_alter(&$trail){
if ($node = menu_get_object()) {
// Get the nid
$tid =$node->field_service_fenlei['und'][0]['tid'];
$links = menu_load_links('main-menu');
// dpm($links);
if($tid == 25){
$trail[0] = 742;
}
if($tid == 26){
$trail[0] = 745;
}
if($tid == 27){
$trail[0] = 744;
}
if($tid == 28){
$trail[0] = 743;
}
if($tid == 29){
$trail[0] = 746;
}
}
}
.sf-menu.sf-style-spring li.active-trail {
background-color: #428bca;
}
.sf-menu.sf-style-spring li.active-trail a {
color: white;
}
.sf-menu.sf-style-spring li.active-trail a:hover {
color: #2a6496;
}
/**
* Implementation of hook_superfish_active_trail_alter().
*/
function mymodule_superfish_active_trail_alter(&$trail){
global $language;
$request_uri = request_uri();
if (strpos($request_uri, '/') === 0){
$request_uri = substr($request_uri, 1);
}
$uri_parts = explode('/', $request_uri);
switch ($uri_parts[0]) {
case 'resources':
if ($language->language == 'en') {
$trail = array(697);
}
else {
$trail = array(1483);
}
break;
case 'workareas':
if ($language->language == 'en') {
$trail = array(759);
}
else {
$trail = array(911);
}
break;
case 'countries':
if ($language->language == 'en') {
$trail = array(758);
}
else {
$trail = array(1482);
}
break;
default:
break;
}
}
/**
* Impelement hook superfish_active_trail
* @param $trail The current active trail
*/
function THEME_superfish_active_trail_alter(&$trail) {
if (count($trail) == 0) {
$links = menu_load_links('main-menu');
$trail[0] = $links[0]['mlid'];
}
}
function my_module_node_view($node, $view_mode, $langcode) {
$tid =$node->field_service_fenlei['und'][0]['tid'];
if($node->type == 'fuwuliebiao' && $view_mode == 'full'){
menu_set_active_item('taxonomy/term/'.$tid);
}
}
if ($node = menu_get_object()) {
// Get the nid
$nid = $node->nid;
}
or
if (arg(0) == 'node' && is_numeric(arg(1))) {
// Get the nid
$nid = arg(1);
// Load the node if you need to
$node = node_load($nid);
}