How it works
- First, the module needs a node. Usually it works on the full node page (but it's not the only use case, see option "Additional path patterns for node detection" below).
- Taxonomy terms are collected from the node. For all selection methods, except "Deepest in lineage", the terms are loaded by core taxonomy function, they are sorted by vocabulary, term weight and term name. For "Deepest in lineage" method the module reloads the tree of terms manually using hierarchy.
- The module selects one term according to settings described below.
- Path is generated for selected taxonomy term. Default path is
taxonomy/term/[tid], but modules are able to override it using hook_term_path(). Also, it is possible to get term path from Taxonomy Menu module.
- This path is set as the deepest selected menu item in active trail.
- Benefit! Menu is expanded to display selected menu item.
Installation and configuration
Installation is simple:
- Download the latest module version.
The module has only one configuration page with all settings on it. First of all, create some taxonomy vocabularies and select node types for these vocabularies. Next, go to Administer >> Site configuration >> Taxonomy Menu Trails and modify settings according to your needs:
- Vocabularies to select terms from
- Here you should select vocabularies that are used to get terms for each node type. You have to select at least one vocabulary for module to work.
- Only if node doesn't have enabled menu item
- The module will come into play only if node has no visible menu items.
- Node's term selection method
- This option defines how the module chooses the term for the active trail:
- First/Last - select first/last term without any checks. Choose this one if you're sure there is a menu item for each term in selected vocabulary. Best performance, because there will be no additional database requests.
- First/last with menu item - find first/last term with enabled menu item. You should use this one if some terms don't have a menu item. Low performance, because of DB queries.
- Deepest in lineage - use deepest term in selected lineage. All parent terms in lineage must be attached to the node for this function to work. It's highly recommended to use Hierarchical Select for lineage saving. Low performance for the same reason.
- Additional path patterns for node detection
- This option is for quite rare use cases and is useless for most of websites. By default the module is trying to detect node at
node/[nid]/*. Here you can specify additional paths to detect node and set menu trail for it. Each additional pattern will be tested on each page load, so use it only if you really need this feature. The "*" character matches any non-empty string, the "%" character matches non-empty string without "/" character. Also, you must include at least one placeholder in each pattern, so module could load the node from the path. Available placeholders:
- [nid] - node ID
- [title] - node title
- Get term's path from Taxonomy Menu modules
- When enabled the module gets term path that is used for taxonomy menu generation. Available only if Taxonomy Menu module is enabled.