I need to use the "path" trail but I also need to display the current term in the breadcrumb. Is there any way to do this currently? Maybe modify the crumbs_reduce_path function? I only want the current term titles in the breadcrumb and not node titles when viewing a node.

Comments

donquixote’s picture

Can you tell me
- what kind of page that is where you want this specific breadcrumb to show up
- which breadcrumb items you intend to see (path and title)
- which breadcrumb items show up instead?

kingdee40’s picture

Well I am using path and it is working as designed.
For Taxonomy term pages:
Continent (term)
-Country (sub term)
--State (sub sub term)
---City (sub sub sub term)

While I am viewing State, it is currently showing up as:
Continent >> Country
Which I expected because path "Chops off the last fragment of the path alias, consider the result as the parent path."

While viewing State I'd like to see
Continent >> Country >> State

Same for City.

And btw, I tried all other breadcrumb modules and Crumbs is the only one that works for me so Thank you.

donquixote’s picture

I see!
What you are looking for is more about display than trail generation.
Crumbs does calculate the complete trail, that includes the page you are currently viewing as the last item.
However, it will then allow the usual breadcrumb display functions to remove that last item, that is, to not display it.

I did consider to make this behavior overridable with Crumbs. However, some themes out there (Zen, in particular) already do this on their own: They provide a checkbox to either show or hide the last fragment. Other themes have other ideas about how the breadcrumb is to be displayed.

This is why I hesitated to let Crumbs mess with the breadcrumb display, and instead behave to those themes as if they were dealing with the core breadcrumb.

However, I do make the full crumbs trail (including the last item) available to theme('breadcrumb') via an extra variable.
This way, themes that know about Crumbs can easily use that last item.

What you can do is implement theme_breadcrumb with your own theme, and do your magic to it.

------

If you have any suggestion how I could improve this to not conflict with "themes that want to be smart", let me know!

kingdee40’s picture

Hmm, maybe my theme isn't crumbs aware, I will have to play with this some more.

Most themes I have used provide control over "Home" settings or last fragment (or both).

I would suggest a "fullpath" -Includes the last fragment of the path alias.

The code would be almost Identical to the "path" but the user would select one or the other.

donquixote’s picture

maybe my theme isn't crumbs aware

I don't know of any theme in contrib that is crumbs aware. Crumbs is simply not known enough to be picked up by contrib themers.
However, your custom theme (which can be a sub-theme of a contrib theme) can easily be made to use the full crumbs trail, by implementing theme_breadcrumb - that is, "MYTHEME_breadcrumb()".

duaelfr’s picture

StatusFileSize
new596 bytes

I agree your position donquixote but in the crumbs.module file around line 146 you pop out the last breadcrumb item and just throw it.
As this element has been built by your module (specially the link_title value), I think it would be usefull to keep it in the final array without adding it to the breadcrumb. As kingdee, I have to output the current page in the breadcrumb and with the actual code I have to rebuild the entire array just to get de title of the last element (see following samples). I hope this humble contribution will help this module to grow because at this day it is the only one which fully meet my needs ;)

Without my patch :

function THEME_breadcrumb($vars){
  $breadcrumb_items = crumbs_build_breadcrumb($vars['crumbs_trail']); // Expensive !!
  
  $links = array();
  $end = array_pop($breadcrumb_items);
  foreach ($breadcrumb_items as $item) {
    $links[] = theme('crumbs_breadcrumb_link', $item);
  }
  $links[] = '<span>' . $end['link_title'] . '</span>';

  $vars['breadcrumb'] = $links;
  return adaptivetheme_breadcrumb($vars);
}

With my patch :

function THEME_breadcrumb($vars){
  $end = array_pop($vars['crumbs_breadcrumb_items']);
  $vars['breadcrumb'][] = '<span>' . $end['link_title'] . '</span>';
  return adaptivetheme_breadcrumb($vars);
}
donquixote’s picture

Status: Active » Needs review
StatusFileSize
new2.02 KB

Nice catch!
I have not touched this part of crumbs for a while..

Here is another patch.
Instead of adding an item that has been previously removed, let's just not remove it :)

With my patch:

function THEME_breadcrumb($vars){
  $vars['breadcrumb'] = $vars['breadcrumb_full'];
  return adaptivetheme_breadcrumb($vars);
}

(or do sth equivalent in a preprocess function)

Warning: This is not tested at all :)

duaelfr’s picture

+1 RTBC

For those who do not want a link on the last breadcrumb item :

function THEME_breadcrumb($vars) {
  if (!drupal_is_front_page()) {
    $end = end($vars['crumbs_breadcrumb_items']);
    $vars['breadcrumb'][] = '<span>' . $end['link_title'] . '</span>';
  }
  return adaptivetheme_breadcrumb($vars);
}
donquixote’s picture

RTBC = you tested?

For those who do not want a link on the last breadcrumb item :

sorry, don't get it..
those who do not want the last item just do nothing.
Those who do want, use the code as in #7..

duaelfr’s picture

Status: Needs review » Reviewed & tested by the community

Yes I tested and it works well thank you.

A lot of people want the current item to appear as the last part of the breadcrumb but not being linked because it would be ergonomically confusing for users. My snippet is for those people ;)

donquixote’s picture

Great!

donquixote’s picture

Thanks a lot DuaelFr!
Did the "no wsod" test, committed and pushed to 7.x-1.x branch.

It will be included in the next point release (I think I should move to beta or rc or stable finally)

donquixote’s picture

Category: support » feature
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

donquixote’s picture

I want to point out a recent change in
#1778236: Rework the way the current page is handled in the breadcrumb

You can play with the -dev version, and post your feedback there!