Problem/Motivation

It is sometimes desired to only show breadcrumbs when they contain more that 1 segment. This is typically for sites where you do not include the Home link as part of the breadcrumb, and you want the current page title to be part of the trail but only when a parent link exists.

This was previously raised in https://www.drupal.org/project/easy_breadcrumb/issues/2908189 but the solution was limited just to the scenario where you do include the home link in the trail.

Proposed resolution

This could be implemented as minimum count given there is already the functionality to set a maximum number of segments.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ericgsmith created an issue. See original summary.

ericgsmith’s picture

Status: Active » Needs review
ericgsmith’s picture

Title: Add option to not render breadcrumb if it contains only a single link » Add option to set a minimum segment length required to render breadcrumbs
greg boggs’s picture

Status: Needs review » Needs work

Awesome feature.

Need a reroll, and lets remove the update hook so folks config doesn't change on them. If folks want to use the feature after they update, they can check the box and when new folks install, they'll get the feature checked by default. This way we aren't changing people's crumbs on update.

ericgsmith’s picture

ericgsmith’s picture

Apologies for taking over a year to respond - I appreciate the review and the feedback.

Coming back to this after a year - the intent of setting the config to 1 is to maintain existing functionality. I believe its good practice to make sure newly introduced config includes an update to set the default value, otherwise we can make the schema nullable. Setting the value to 1 is not changing any existing behaviour.

I do find the UI confusing - and I think when you say "can check the box" when they install, that it looks like the other settings on the form are related / have control over this. That is my mistake for positioning the field next to that - I didn't really look close enough at the existing behaviour of that option first. That "Limit breadcrumb trail segments" is from #3174165: How to support limiting depth and to be honest I'm still a bit confused by it - because I think the wording of the label and the functionality is a bit different 😅 But, I don't want to confuse this feature request with that functionality - I think it will be clearer if I make the UI clearer what this field does.

Perhaps it would be better to move this new field down into the Advanced settings - I prefer the UX of the form fields there that are enabled by a checkbox and then have the field value only shown when checked. I could refactor it so its like this:

I think that wording makes it a bit clearer too?

(Values in the screenshot just an example of how I'm using it - not suggesting we default to 2)

greg boggs’s picture

ok got it! Sounds like we can include this as is.

greg boggs’s picture

Status: Needs work » Fixed
ericgsmith’s picture

Ah thanks @Greg - I just pushed with the suggested change - all good if we don't need it - thanks for the review!

  • Greg Boggs committed 15319fe5 on feature/megre_dynamic-breadcrumbs authored by ericgsmith
    Issue #3309109 by ericgsmith: Add option to set a minimum segment length...

Status: Fixed » Closed (fixed)

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