Closed (won't fix)
Project:
Taxonomy Breadcrumb
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
8 Jun 2012 at 18:26 UTC
Updated:
3 Oct 2012 at 09:45 UTC
I think it would be of great value to this module to also set the active menu item when viewing a node. This way menu items in the active trail will get the 'active-trail' class, the active menu item itself will also get the 'active' class.
I'm not good with patches, so I'm going to do it this way: in taxonomy_breadcrumb.inc in function _taxonomy_breadcrumb_generate_breadcrumb() we could add the following lines:
// Generate the TERM breadcrumb.
$parent_terms = array_reverse(taxonomy_get_parents_all($tid));
+
+ // if we are not on a term page, set the active menu item so the active trail is also shown in menu's
+ if (!$is_term_page) {
+ $parent_terms_length = COUNT($parent_terms);
+ if ($parent_terms_length && isset($parent_terms[$parent_terms_length - 1]->tid)) {
+ menu_set_active_item('taxonomy/term/' . $parent_terms[$parent_terms_length - 1]->tid);
+ }
+ }
Comments
Comment #1
lmeurs commentedAiaiai, though this does set a new active trail, it also binds the primary tabs (View, Edit, etc. buttons) to the newly set active term instead of the node we are viewing.
Luckily the node itself still is editable through the contextual links menu, if this module is enabled. But there must be another way to set the active menu trail and still make the current node the active node.
Advantage of using
menu_set_active_item()is that we do not have to specify a specific menu as withmenu_tree_set_path()...Comment #2
jantoine commented@lmeurs,
When viewing a node, Drupal automatically handles setting the active menu item for that node. It is incorrect to set the active menu item for the top level term of the node. If I have misunderstood what you were trying to accomplish, please reopen the issue.
Comment #3
lmeurs commented@AntoineSolutions: I think that in a particular case I loaded a node within another node through some sort token in the body field. This token was replaced by a module of ours with the node, I was hoping to set this node active in the menu. But to be honest, I do not remember exactly what the case was, so please, lets keep the issue closed... :-)