Problem/Motivation

Easy breadcrumb builds the text for the breadcrumb links from multiple sources, including the content title, route title, menu link text, and path. The text for each is run through the normalizeText() function, which replaces hyphen and underscore characters with a space character. This makes sense for text sourced from the path where these characters are commonly used as a separator between words, but may not be the desired behavior when the text is sourced from the title of content. For example, it would remove the hyphen in "Non-discrimination Statement".

Steps to reproduce

1. Enable Easy Breadcrumb and check the "Use the real page title when available" in its configuration.
2. Create a page with a title including a hyphen or underscore.
3. When a link to the page appears in breadcrumbs the hyphen or underscore will be replaced with a space.

Proposed resolution

The simplest resolution would be to move the string replacement functionality to the places in the EasyBreadcrumbBuilder class where paths are passed to normalizeText(). I will attach a patch that does this.

A more robust solution would be to include the source of the text as a parameter to normalizeText() and use that to determine whether to remove these characters. Additionally, the admin configuration could allow site builders to configure whether to keep or remove these characters for each of the source types (route, menu, path, front page, etc.).

Remaining tasks

If you would like to go in the more complex direction described above I can create a patch which implements that solution.

User interface changes

The more complex solution would add checkboxes to the admin configuration form.

API changes

None.

Data model changes

The more complex solution would store an additional configuration string.

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:

    1 hidden branch
  • 8.x-1.x Comparechanges, plain diff MR !2

Comments

i.mcbride created an issue. See original summary.

i.mcbride’s picture

greg boggs’s picture

Configuration would be ideal. Because otherwise we will change existing websites when people update.

greg boggs’s picture

Great Feature though, thanks for adding. I honestly can't remember why we remove dashes! heh. :)

i.mcbride’s picture

I think the removal of these characters comes from the Drupal 7 version of the module where you have fewer sources to create the breadcrumb and it makes sense for the case where the text comes from the path.

I'm attaching a patch which allows the site admin to choose when to apply the replacement. New installs will have it turned on for just the path while existing installs will fall back to the current behavior of always applying the replacement until a site admin changes this.

greg boggs’s picture

oh! Now that I see your code and understand, I think we should just make it so the module always removes - and _ but only when the path is from the URL, no config option needed.... what do you think?

i.mcbride’s picture

I'm fine with either approach. I believe the patch in #2 implements the solution you propose in #6, though it does introduce new behavior into existing installations. If you'd like me to roll up the code to handle it differently, I'm happy to do so.

amklose’s picture

If I'm not mistaken, the 8.x module used to allow hyphens from the node title in the breadcrumb - specifically 8.x-1.12. I just noticed that it changed when updating to 1.13 on a staging site and comparing it to live. The hyphen exists on live but not on the updated site.

amklose’s picture

Could it be an unexpected side effect of this commit? https://git.drupalcode.org/project/easy_breadcrumb/-/commit/1d3d34a4ab60...

jennypanighetti’s picture

I'm having a similar issue with capitalization. We have page titles which start with a lowercase letter - it's a product name, so it needs to stay that way - but EasyBreadcrumbBuilder.php line 437, $title = $this->normalizeText($this->getTitleString($route_request, $route_match, $replacedTitles)); - the $this->normalizeText() capitalizes the first word. We DO NOT want that.

The Easy Breadcrumb configuration "Transformation mode" option is set to "None," so I would think normalizeText() could be removed in this case. I realize it would change existing sites, so a new config option could be "Do not normalize."

jennypanighetti’s picture

I think my issue is different enough that I'll open a new ticket for it!

johnhelmuth’s picture

ahmad smhan’s picture

Patch to dev after update

ahmad smhan’s picture

ahmad smhan’s picture

StatusFileSize
new15.48 KB

mandclu’s picture

Status: Active » Needs work

The patch from #16 would not apply via composer for me.

mandclu’s picture

Status: Needs work » Needs review
StatusFileSize
new8.79 KB

Attempting to re-roll for dev.

greg boggs’s picture

I think we actually want patch from #2 in this issue rather than a reroll of 14. 14 adds a configuration option that we don't really need because it's reasonable to just fix the bug without an option to not fix it.

I realize I originally suggested adding a config option for this, but I think that's because I was confused when I read the original issue.

If we do add a config option for this, this patch is missing the config schema changes needed for config settings translation and testing support.

antoniya’s picture

+1 for not adding another config option. Keeping dashes in breadcrumb titles used to be the default behavior prior to 1.13.

greg boggs’s picture

Status: Needs review » Needs work
mikemccaffrey’s picture

So what still needs work with this issue? The patch from #2 still applies cleanly to the 2.0 version of the module, and it would be great to have it committed to dev.

greg boggs’s picture

Version: 8.x-1.x-dev » 2.x-dev
Status: Needs work » Fixed

Thanks for finishing this one out Mike.

  • Greg Boggs committed 3417d78 on 2.x authored by mandclu
    Issue #3161100 by Ahmad Smhan, i.mcbride, mandclu, Greg Boggs,...

Status: Fixed » Closed (fixed)

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