0

I’m using Drupal 7.5.2 and am attempting to use the Crumbs module (version 7x-2.5) to show parent and child paths in the breadcrumbs trail and it’s not working.

My URL alias structure—which I am attempting to recreate in the breadcrumbs—is as follows:

  • My Great Node Pile: A view page that is neither taxonomy term or a node.
  • Category: A view page that is connected to the parent taxonomy term.
  • Category Child: A view page that is connected to the child taxonomy term.
  • Node: The node associated within that parent category and child category.

Only one category—child or parent category—can be associated to a node at any given time.

My “Entity Parent” settings for all node content types is as follows; note all content is based in the path of my-great-node-pile/ which is a stand-alone view that is simply the “home base” for this stuff; it is neither a taxonomy term parent item or a child item:

my-great-node-pile/[node:field_category:parent]/[node:field_category]

So if I have a node that resides in the aliased area of “My Great Node Pile” titled “Cool Stuff” that has this parent/child taxonomy term URL structure; using Pathauto for that so do not take this pseudeo-example 100% literally:

my-great-node-pile/field-category/field-category-child/cool-stuff

Then I would expect my breadcrumb trail to be this:

My Great Node » Category » Category Child » Cool Stuff

But with the default Crumbs settings, this is the bizarre breadcrumb trail I am getting:

My Great Node » Category Child » My Great Node » Cool Stuff

What? If the entity parent is [node:field_category:parent]/[node:field_category] then why is it apprarently rendering as [node:field_category]/My Great Node?

Example Note: The names of items here—including tokens—are neutralized to protect anonymity of the project, but I assure you all tokens and examples here are proven to have the values they should have via the output of the Devel (version 7.x-1.5) module.

4
  • Hi! I am about to write an answer to this, which I hope will clarify things for other readers too. Maybe you could add more information to the question and use example names that allow a better distinction of nodes vs terms? E.g. in your example "Parent stuff" and "Child thing" are a terms, but "Cool stuff" is a node? And "My great node" is possibly a views page which is neither a term nor a node? Also if you can, specify urls or paths for each breadcrumb item.
    – donquixote
    Dec 3, 2016 at 7:56
  • And what is [node:category]? I imagine you have a taxonomy term reference field, so it would rather be sth like [node:field-category:1:tid].
    – donquixote
    Dec 3, 2016 at 8:06
  • @donquixote Sorry, but while I appreciate your effort—and your notes have helped me clarify the question—this is ultimately a self-answered question where doing what I outline in my answer is what ultimately solved the problem outlined which is simply stated: If I have a parent/child taxonomy term structure, why does it behave oddly and render incorrectly when using Crumbs via default settings? Simply adding path from Crumbs from “Disabled by default” to “Enabled” is what solved the problem. Dec 3, 2016 at 17:55
  • 1
    A said below, imo the goal of stackexchange should be to produce Q/A content that will be useful to more people than just the original poster. If people get here from google, they should be provided with useful information that is generic enough to apply to their case.
    – donquixote
    Dec 4, 2016 at 20:38

2 Answers 2

0

After spending more time than I wanted to to dealing with this—exploring solutions and Googling seemingly forever—I came across this post on the official Drupal site titled “Crumbs not working” and specifically this answer from ‘donquixote’ which states:

  • are these system paths or node aliases? If they are node aliases, do you have the "path" plugin enabled? (*)

Okay, so that seems like an idea. So I went into the Crumbs settings area under “Structure > Crumbs” and dragged the path setting—which describes itself as “Chop off the last fragment of the path alias, consider the result as the parent path.”—from “Disabled by default” to the second position of “Enabled” (see attached screenshot), hit “Save configuration” and… et voilà… It works! Parent and child taxonomy terms are being rendered in the breadcrumb path as expected.

enter image description here

1
  • 1
    This does not answer the "why does it behave oddly and render incorrectly" part of your question - just saying.
    – donquixote
    Dec 4, 2016 at 20:40
0

One important thing to notice is that Crumbs trail-finding works recursively.

Every rule in "Entity parent" or in the main plugin configuration page is only there to specify the direct parent page.

The rest of the trail, like the grandparent, grand-grandparent etc are determined via recursion.

About your example

My “Entity Parent” settings for all node content types is as follows; note all content is based in the path of my-great-node-pile/:

my-great-node-pile/[node:category:parent]/[node:category]

I suspect that the token string does not work.

First, [node:category] should probably be something like [node:field_category] if you are using a taxonomy term reference field.

Secondly, I recommend to specify the system path of the node's category, not the alias: taxonomy/term/[node:field-category:1:tid]. Notice the - instead of _. This is just how tokens work, apparently.

Thirdly, what you really should do instead, is use the already-existing plugin for taxonomy.termReference.field_categories.node.*.

Proposed solution

On admin/structure/crumbs:

First, enable the taxonomy.termReference.field_categories.node.* (replace field_categories with the field name of your choice). This tells Crumbs that the parent page of a node should be the category.

Then, enable taxonomy.termParent.* or leave it in the "Inherit" section. This tells Crumbs that the parent page for a category should be the parent category.

Finally, go to admin/structure/crumbs/entity-parent/taxonomy-term and set my-great-node-pile as the parent path for categories.

Alternative I: The "path" plugin.

If you sure that your aliases are all perfect, you could simply work with the "path" plugin alone, as you already proposed.

If you do this, you can remove the "Entity parent" token strings.

But beware that this requires your aliases are all working correctly. E.g. if for some reason you have one node with the wrong alias, then your breadcrumbs will break down for this node.

Alternative II: "Easy breadcrumb" module

Basically, Easy breadcrumb is equivalent to Crumbs with ONLY the "path" plugin.

If you are sure your aliases are perfect, and you are not interested in any of the other functionality in Crumbs, then Easy breadcrumb can be for you.

It does not give you the deep recursion like Crumbs. E.g. if you visit a node/123 which has an alias, and then go to node/123/edit, which does not have an alias, then Crumbs will preserve the beginning of the breadcrumb, while with Easy breadcrumb you will lose most of the breadcrumb on the node edit page.

Troubleshooting: Crumbs "Debug" tab

Notice that the "Debug" tab is there for a reason..

6
  • Your answer doesn’t solve a problem; this is a self-answered question where I present an answer that works 100% fine for the situation presented. Perhaps my example—in which I have attempted to neutralize personal details of naming schemes from the client’s site with new names—needed to be more carefully setup to avoid confusion, but I assure you the scenario I provide as an example is saved perfectly by my answer. Dec 3, 2016 at 17:46
  • 1
    The main intent of my reply is not primarily to help you personally, but to make this a useful Q/A for other readers. Your answer might work for you, but I think it might be misleading to other readers in some cases, and it does not explain the background and why this works.
    – donquixote
    Dec 4, 2016 at 20:35
  • @donquixote I take you are the maintainer of the module the question is about? This is important, because in that case you are objectively more prepared to answer this question.
    – apaderno
    Dec 5, 2016 at 7:44
  • Yes, I am the maintainer, and I am following the "breadcrumbs" tag to get feedback and better understand how people use the module, and in the hope that I can educate people.
    – donquixote
    Dec 5, 2016 at 8:44
  • And I am often annoyed on stackexchange sites if I find "worksforme" answers that do not help anyone else. Or issues on drupal.org that were closed for this reason.
    – donquixote
    Dec 5, 2016 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.