Many modules do a drupal_set_breadcrumb() to override the breadcrumb.
Crumbs, of course, completely ignores that, and does it's own breadcrumb calculation, and I consider that a good thing.

However, a "legacy" plugin could be written that does a drupal_get_breadcrumb(), compares that to menu_get_active_breadcrumb(), and if the two don't match (meaning that the breadcrumb was overridden), sets the breadcrumb to the one received from drupal_get_breadcrumb().

This would allow users to optionally take the old breadcrumb into account, as well as control the priority of that (allowing other plugins to take precedence).

I don't personally need this, but describing it as a feature request in case someone else wants it.

Related: #1794762: Don't calculate the breadcrumb if the existing one is blank.

Comments

donquixote’s picture

#993378-3: Crumbs not compatible with Drupal API

In the 6.x-2.x branch, crumbs_get_trail() is designed to be called during hook_init(), so modules like sections or context can use the trail to determine the current section or context, and thus, the current theme.

drupal_set_breadcrumb() is usually set during the page callback, which is far too late for theme switching. Thus, there is no healthy way that crumbs could support drupal_set_breadcrumb().

Another issue:
drupal_set_breadcrumb() does not trickle down to sub-pages.
E.g.:
- page B has a breadcrumb of Home > A > B due to drupal_set_breadcrumb().
- page C has a crumbs parent of B.
- when visiting C, crumbs does not know about the drupal_set_breadcrumb() for B, so the resulting breadcrumb will be Home > B > C, instead of Home > A > B > C.

Of course we could decide to just live with that.

And yet another issue:
Typically you want this legacy rule to work only on some pages, not all. Or you might want to use only a part of the breadcrumb defined this way. Now we want to split it up into sub-rules like crumbs.legacy.foo and crumbs.legacy.bar. But how can we knoe which module called drupal_set_breadcrumb? And how could the user know?

bojanz’s picture

Priority: Normal » Minor

So, the two assumptions in #1 are:

1) The "legacy" breadcrumb can't be used by context or themekey.
2) It provides an inconsistent user experience.

Both are true, but I think they are acceptable to someone who would want a legacy plugin.
Still, I couldn't find a single legitimate use of drupal_set_breadcrumb($something) in contrib, so I'm degrading the priority of this to "minor".
At least there's a description of what needs to be done if someone actually needs it and wants to write it.

bojanz’s picture

So, the two assumptions in #1 are:

1) The "legacy" breadcrumb can't be used by context or themekey.
2) It provides an inconsistent user experience.

Both are true, but I think they are acceptable to someone who would want a legacy plugin.
Still, I couldn't find a single legitimate use of drupal_set_breadcrumb($something) in contrib, so I'm degrading the priority of this to "minor".
At least there's a description of what needs to be done if someone actually needs it and wants to write it.

donquixote’s picture

See #1914718: Crumbs on Views with Arguments/Contextual Filters
Views pages with contextual filter arguments use drupal_set_breadcrumb(). And it is pretty hard to reconstruct the Views breadcrumb in other ways. Especially, because the stuff that Views puts into the menu_router table is quite useless. No title callback etc.

The nice thing: crumbs_get_trail() might happen early in bootstrap. But crumbs_get_breadcrumb() does not!
So, we may not want to use drupal_get_breadcrumb() for findParent(), but we can use it for findTitle() !

Still, I wonder if a generic "legacy" plugin is the right way to do it. One reason being that it would be super intransparent, and you have no fine-grained control over when it is used and when it is not used.

But we could use it for views.