I am using the pb-join tokens to get a taxonomy based breadcrumb. It works fine if there is just one term attached to the node, but if there are multiple terms assigned, I only get a breadcrumb for the first term.

I am using the Multiple Selects module and have a field where multiple terms can be assigned. Many of my items have been tagged like this:

cat1
cat1 - subcat a
cat1 - subcat a - subsubcat 1

now, I think they should just be tagged with 'cat1 - subcat a - subsubcat 1', but this is legacy data and it is unlikely I will be allowed to change this. The breadcrumb just gets generated like:

home > cat1

and I'd like:

home > cat1 > subcat a > subsubcat 1

It seems like PB is taking the shortest or 'lightest' term. Is there any trick to get around this? I noticed basically the same issue in the Taxonomy Breadcrumb issue queue:

https://drupal.org/node/1850040

So I know similar modules function the same way and people are interested in solving the same problem.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kalabro’s picture

Category: Support request » Feature request

Hello,

It seems like PB is taking the shortest or 'lightest' term.

PB just takes the first term in array of terms (similar to %node:field-tags:0). It is default behaviour for tokens. I guess what you want is taking the most deepest term instead. It looks like good feature request, so I change issue status.

kalabro’s picture

Priority: Normal » Major

Let's do this.

meecect’s picture

You probably noticed, I raised another similar issue, with some alternative approaches:

https://www.drupal.org/node/2320149

Plazik’s picture

You can control multiple parents using parents-all:0, parents-all:1, etc.

Nikita Petrov’s picture

FileSize
8.35 KB

When I was thinking about the place where we should integrate that functionality I came up with the following idea: we can't write some token for the taxonomy_reference field because it shoudn't be necessary the longest taxonomy chain at all. For example, a node could have two values in the 'Category' taxonomy_reference field: '1) Virtual -> Programming 2) Thinking -> Great ideas. Which of them our module should use? It is up to the content manager. Therefore, we need the ability for user to choose, what exactly taxonomy chain we should use for breadcrumbs for each node. Therefore, we need some setting in the node edit form to do it. But we shouldn't write any code for implementing that - we can just create a separate field, for example, 'field_breadcrumbs_chain", with the taxonomy(or entity)_reference type, with widget whatever you like (for example, Simple hierarchical select, you can choose 'Force selection of deepest level' but it is not necessarily), AND (important) with Number of values = only 1. The content manager will be forced to choose the right breadcrumbs chain (we can mark this field as required), and he/she will be able to choose the different chains for different nodes. For example, we may have the following situation: the 'Category' field may have 2 values: 1) Personal 2) Other -> Garbage. But content manager may want to assign the 'home' -> 'personal' breadcrumb for that node instead of garbage, but it is the shortest chain. With the configuration I described above he/she will be able to do it.

Conclusion: use a separate taxonomy_reference field with Number of values = 1, and use it for the Path Breadcrumbs module like %node:field-breadcrumb-chain:pb-join:name/url.

To maintainers: please, mark that and related issues as 'closed' if I described the right approach. Thank you.

kalabro’s picture

Thanks for sharing your workarounds @Plazic and Nikita Petrov!

The common problem is that site builders first create site architecture and content and then think about breadcrumbs :)

In this thread we are discussing the possibility to make pb-join token smarter by using the deepest term in multivalue fields. This should increase usability for those who store all chain of terms in one field.