So I had a heck of a time even getting any form of Menu Trails working on my site, and while that's neither here nor there, I think a quick touch on the modules involved might help the picture a bit...

Essentially I wanted the same thing as the last person to post an issue on this module - my Custom Breadcrumbs are generated based on my Pathauto output of Hierarchical Select's 'save term lineage path' (which also required some fixing, incidentally... I recommend anyone having trouble dive into the HS issues queue) on Taxonomy terms (actually Content Taxonomy but w/e)

The problem was, the Pathauto tokens from Hierarchical Select choose the first parent item in the list of taxonomy terms (which is normally fed in alphabetically?) for an article (actually the first parent per vid, more in HS issue queue, but others are broken essentially) and checks it for any child terms - the selected path is the child term if it exists, otherwise it's the parent term.

A few background items may help as well:
Taxonomy Redirect - my taxonomy terms are overwritten by views with their own custom URLs, not taxonomy URL overwrites
Taxonomy Menu - actually thinks it's linking to my 'taxonomy/term/tid' pages, Taxonomy Redirect alters the links at the theme layer

These two together mean that any Taxonomy Menu Trail setting that does not include 'Get paths from Taxonomy Menu' will fail horribly, but that's really neither here nor there, as that's what that setting is for, eh? ;)

Anyhow, back to the point at hand, I realized there were essentially two options:
1) Parse the current path, and then find the appropriate taxonomy term path to return based on that (not a bad solution, I suppose? but I was worried about how much poking around in the database I'd actually have to do to start from term name in the path instead of the readilly available node tids)

2) Add a new selection type to Taxonomy Menu Trails that follows HS/Pathauto rules:

The stuff at the top comes from a Hierarchical Select and has to do with inconsistencies in the way Drupal allows Taxonomy terms to be passed around, it really ought to be relatively extraneous, but I had the code on-hand from fixing HS, so I used it.

It's also relevant to note that I took some shortcuts in hopes of avoiding extra database calls, like forcibly calling the
taxonomy_menu path creation rather than using the proper operator (so I don't need to call get_term), and doing my database calls manually rather than using the get_term, get_parent and get_children taxonomy functions...

(maybe I'm wrong here about boosting efficiency? it's been so so so long since I've worked directly with a database... if I'm horribly bogging down my system with this from things I'm not seeing, I'd love someone to tell me about it ;)

Mind you I don't REALLY expect the author to do anything about this - but I had a hell of a time finding a complete solution, so I'm posting it here just in case some day someone finds this issue useful ;)

at line 35 of taxonomy_menu_trails.admin.inc

<?php
       
'hs-taxonomy' => t('HS Taxonomy'),
?>

and at line 46 of taxonomy_menu_trails.inc

<?php
   
case 'hs-taxonomy':
      foreach (
$taxonomy as $key => $term_item) {
        if (
is_object($term_item)) {
         
$terms_by_vocab[$term_item->vid][] = $term_item->tid;
        } else if (
is_array($term_item)) {
         
$terms_by_vocab[$key] = $term_item;
        }
        else if (
$term_item) {
         
$current_term = taxonomy_get_term($term_item);
         
$terms_by_vocab[$current_term->vid][] = $current_term->tid;
        }
      }
      foreach (array(
2,3) as $count) {
        if (
$terms_by_vocab[$count]) {
         
$db_results = db_query(db_rewrite_sql("SELECT t.tid FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.tid = t.tid WHERE (t.vid = '".$count."') AND (h.parent = 0)", 't', 'tid'));
          while(
$parent_term = db_result($db_results)) {
           
$parent_terms[] = $parent_term;
          }
          foreach (
$terms_by_vocab[$count] as $current_term) {
            if (
array_search($current_term, $parent_terms)) {
            if (
array_search($current_term, $parent_terms)) {
             
$db_results = db_query(db_rewrite_sql("SELECT t.tid FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.tid = t.tid WHERE (t.vid = '".$count."') AND (h.parent = ".$current_term.")", 't', 'tid'));
              while(
$current_child = db_result($db_results)) {
               
$current_children[] = $current_child;
              }
             
$current_children = array_intersect($terms_by_vocab[$count], $current_children);
              if (
$current_children) {
                if (
is_array($current_children)) {
                 
$hs_terms[$count] = $current_children[0];
                } else {
$hs_terms[$count] = $current_children; }
              } else {
$hs_terms[$count] = $current_term; }
              break;
            }
          }
        }
      }
     
$term = end($hs_terms);
     
$href = taxonomy_menu_create_path(end(array_keys($hs_terms)), $term);
      break;
?>

Comments

I suppose I should also point out - the taxonomies I'm using Hierarchical Select on are hard coded in there at line 13 - array(2,3) and line 37 end($hs_terms)

a more complete solution would probably ask Hierarchical Select what taxonomies it's enabled on and select the first - reset($hs_terms) - which is the default option if you patch HS so that its collective term-path token works - but that wouldn't have worked well for me since I have content that has only terms in vid2, and content that has terms in both vid2 optionally and terms in vid3, but is always indexed based on vid3.

Asking Content Taxonomy to tell me the first non-optional taxonomy might've worked, but hard coding it was just easier ;)

EDIT: another complete solution might be to just ask on the Taxonomy Menu Trail admin page which taxonomies to use per node-type using a vid sorted multi-select to set the values I use as array(2,3) and then use reset(hs_terms) ?

Priority:Minor» Normal

Subscribing, trails not working using taxonomy_meu hierarchical pat, , may be working wth these additions.
greetings, Martijn

Status:Active» Fixed

Please, check 6.x-1.1 release. It adds two important features:

  • For each content type you can select vocabularies now
  • There is a new selecting method "Deepest in lineage" which is recommended to use with HS and "save term lineage path" enabled

So, I'm marking issue as fixed.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.