Hi,

I have problem forcing breadcrumbs on nodes of type product_display (a Commerce setup, each product display refers to a product entity).

Each product display has two term references on it, each term from separate vocabularies, which are: Product type and Application.
I enable user to browse through products from either category using taxonomy menus. When user hits a product_display node, I want the URL path as well as breadcrumbs indicate the Application context, regardless of from where visitor came.

My paths are performing ok. I have the following patterns:

<strong>Pattern for all Product display paths</strong>
[node:field-kateg-zastos:url:path]/[node:field-product:sku]

(field-kateg-zastos is a term reference field linking to the Application vocab)

<strong>Default path pattern (applies to all vocabularies with blank patterns below)</strong>
[term:vocabulary:name]/[term:parent:parent:parent:parent:parent:name]/[term:parent:parent:parent:parent:name]/[term:parent:parent:parent:name]/[term:parent:parent:name]/[term:parent:name]/[term:name]

(this is a long pattern with some depth overhead compared to maximum depth found in the tree)

The problem is with breadcrumbs, which always indicate the Product Type context. I tried various combinations with no desired effect. Usually I keep the "Use the taxonomy hierarchy to set the breadcrumb trail for nodes and taxonomy pages" checked.

a) when I narrowed the vocabulary to only Application type, the breadcrumbs disappeared, which - to me - indicated that the other context is simply unavailable.
b) when I tried to define a Path or Node custom breadcrumb, the breadcrumbs were altered (which shows they are likely to be managed), but I had trouble setting up a smart pattern. The problem is that nodes have various branch depths throughout the tree.

I tried a similar pattern with depth overhead, but it exceeded the allowed length.

Would you suggest anything? Please let me know if you need some additional info.
Thanks for your time.

Comments

moniuch’s picture

What would help would be if you tested the module on a site where a node of a given type is tagged with 2 different taxonomies and you want to assign a *particular* one to be source of breadcrumbs for that type. Make sure the taxonomy is hierarchical and has variable depth at different branches. This exposes problem of defining a flexible pattern, such as Pathauto provides, which copes with variable depths.

zylootino’s picture

@moniuch: I have the same issue. Did you find a suitable solution?

moniuch’s picture

Yep, I gradually migrate all my sites to Path Breadcrumbs, a new powerful and actively maintained module. There you can contextually select a path branch and force to use tokens from a given taxonomy.

g089h515r806’s picture

I solve it. in file custom_breadcrumbs\custom_breadcrumbs_taxonomy\custom_breadcrumbs_taxonomy.inc,
changge the code of function "custom_breadcrumbs_taxonomy_node_get_terms" :

function custom_breadcrumbs_taxonomy_node_get_terms($node, $key = 'tid') {
  static $terms;
  if (isset($node->nid) && isset($node->vid)) {
    if (!isset($terms[$node->vid][$key])) {
      $query = db_select('taxonomy_index', 'r');
      $t_alias = $query->join('taxonomy_term_data', 't', 'r.tid = t.tid');
      $v_alias = $query->join('taxonomy_vocabulary', 'v', 't.vid = v.vid');
      $query->fields( $t_alias );
      $query->condition("r.nid", $node->nid);
      $query->orderBy("v.weight", 'ASC');
      $result = $query->execute();
      $terms[$node->vid][$key] = array();
      foreach ($result as $term) {
        $terms[$node->vid][$key][$term->$key] = $term;
      }
    }
    return $terms[$node->vid][$key];
  }
  return array();
}

This line was added by me:

$query->orderBy("v.weight", 'ASC');
g089h515r806’s picture

Here is the patch.

g089h515r806’s picture

Category: support » bug
Status: Active » Needs review

It is a bug, change status to "needs review".

(1), the term whose vocabulary's weight is lightest will be used as node's term.
(2),Site builder could change the weight of vocabulary at page admin/structure/taxonomy.

wemmies’s picture

Thnx, applied the patch, changed the weight and got things the way I wanted. Things seem to work.

Not to critice (as I don't know how to code these things), but to help the thoughttrain:
A nicer sollution would be not to let it depend on weight, but on the vocab selected.

colan’s picture

Status: Needs review » Closed (duplicate)

See #1338104: Lightest vocabulary and terms not working. If there's more to do, please reopen that one.