- Issue created by @ammaletu
- π©πͺGermany spuky
I guess your bug is other Peoples feature...
and the change was in [3196198]
- π©πͺGermany ammaletu Bonn, Germany
I don't think this is about treating the exclusion string as a regex or not. The same thing happens if I put a regex in the exclude config instead of simply the string "node". I just tried it with "node\/[0-9]+" and still didn't get breadcrumbs beyong the Home link.
The question is against what part of the URL the regex is run. If you actually want to run it against the whole URL, then there's no point in doing it more than once. But since the exclude feature is there to remove parts of the URL, this doesn't sound right to me.
Also, I noticed that there doesn't seem to be a test case for the exclude feature.
- π©πͺGermany spuky
I would guess you where counting on a bug with the field
now the behavior is..
below an entered path there are no more segments generated (including the page title)kat1
--kat1-1
----kat1-1-1
------kat1-1-1-1
--kat1-2
----kat-1-2-1having that
i can use kat1\/kat1-1\/kat1-1-1
to hide everything below the path from the breadcrumb.
I was not involved in the bugfix for the feature... ( Just happend to roll the release where the change was included)
but from reading the description of excluding paths.. i would have guessed that what it does...excluding paths not segments..so putting /node in there hides elements for everything below /node wich describes your behavior...
I see your use case... though
And there is a solution with using:
Paths to replace with custom breadcrumbs
regex!/node/([0-9]*)::
this is not easy to discover unless you know your way around that feature but should give you a first working solution
so my Suggestion would be:
We close this issue as Works as designed...
and open a Feature Request to make an easy Option to Skip SegmentsAnd yes you are right we are missing lots of test cases (feel free to provide MRs with additional tests )
- π©πͺGermany spuky
Paths to replace with custom breadcrumbs
regex!/node/([0-9]*)::
No that does not help... since it is matching on both url alias and internal path... looked good on first try... but...when checking another node with an alias it also matched..
- π©πͺGermany spuky
Ok figured it out you must set both:
Paths to be excluded while generating segments:
\/node\/
Paths to replace with custom breadcrumbs:
regex!/node/([0-9]*/)::
- π·π΄Romania bbu23
Indeed, I have the same issue. I updated the module from 2.0.5 to 2.0.8, and now the existing breadcrumbs are not being displayed at all anymore.
- π©πͺGermany spuky
could you share a little more about what breadcrumbs are not there with which config... ?
- π·π΄Romania bbu23
I will have to gather more info, that was what I observed immediately after the update. Though on my multisite, one of the breadcrumbs were showing. So, I will check why the other doesn't and when I have more info I'll get back here.
- πΊπΈUnited States attheshow
We had some dynamically built pages (not nodes or entities, but with the body of the page being built on the fly via external API calls) that had aliases like /catalog/. Those previously had breadcrumbs like Catalog > 1234 being shown in version 2.0.7 but those are no longer appearing in 2.0.8.
- π©πͺGermany spuky
@atteshow.. could you share more about your config.. any exclusions set ?
- πΊπΈUnited States attheshow
@spuky It doesn't look like we have any exclusions set in the config (https://gist.github.com/attheshow/4cbb070ed15cd1c955c6f0158ad8f87b). I'm trying to think of what else might cause the issue... I wonder if it could be something in our existing implementation of hook_preprocess_breadcrumb() that's not playing nicely with the latest code.
- π·π΄Romania bbu23
@spuky here's the exact problem that I have:
- I'm using exclude paths
- The only value present is one path. E.g.something
- The page that I am visiting is: /something/should/not/be/included
- The breadcrumb doesn't showAfter investigation, here's what I got:
File
web/modules/contrib/easy_breadcrumb/src/EasyBreadcrumbBuilder.php
(going to reference the exact lines from here https://git.drupalcode.org/project/easy_breadcrumb/-/blob/2.x/src/EasyBr...)line 504: Adds the language (will matter later)
line 531: The most problematic one, basically this one will always return true for my case. While each sets of paths are being checked, "something" is always present and the regex check from line 527 is always true, therefore all paths are being excluded, whereas I want only the first part (something) to be excluded.
BUT, if I remove the regex completely to use the exact match instead (since I don't need it and just to check) here comes line 504, which by the time it gets to "/something", it will be'something' == '/en/something'
Regex is not really a good idea for this type of scenario. Or maybe improved, or allow us to en/dis regex, or idk. And the exact match should not use the language, it always fails.
I hope this helps.
- π·π΄Romania bbu23
I created a local custom patch for my particular case, not sharing it here because it's not general and definitely impacts others. I'm just sharing what I changed for informational purposes:
1. Removed the use of
$add_langcode
2. Removed the langcode and slash from the
$check_path
Before:$check_path = '/' . implode('/', $path_elements); if ($add_langcode) { $check_path = '/' . $curr_lang . $check_path; }
After:
$check_path = implode('/', $path_elements);
3. Completely removed regex
The following code removed:$regex_match_found = FALSE; $exclude_is_regex = !@preg_match($escaped_exclude_segment, NULL); // Check path against exclude segment. if ($exclude_is_regex === TRUE) { $regex_match_found = preg_match('/' . $escaped_exclude_segment . '/', $check_path, $matches); }
and this bit replaced:
before:if ($regex_match_found || $escaped_exclude_segment == $check_path) {
after:
if ($escaped_exclude_segment == $check_path) {
- π©πͺGermany ammaletu Bonn, Germany
@spuky (see #6): I think I got this to work now. I did not use "Paths to be excluded while generating segments". As soon as that contains "node", no breadcrumbs are generated anymore, because there is nothing in front of "node" to generate a segment.
Instead, I used "Paths to replace with custom breadcrumbs" with:
regex!/node/([0-9]*) :: <title>
That seems to do the trick.
Another question is, why this is even necessary for nodes? This works out of the box for groups (/de/group/123) and for users (/user/42). They each get a breadcrumb like "Startpage > Unlinked Title". Only nodes get "Startpage > > Unlinked Title". So maybe the real bug is this empty segment for nodes?
- π¬π§United Kingdom gsquirrel London
I am also experiencing this issue
Previously it worked fine to exclude just one segment of the url (which did not correspond to a page). Now if I have that in the exclude section I get no breadcrumbs at all.
This is since the update to latest version.
My use case - I have a pages with urls like this: /toolkit/getting-started/normative-frameworks-cse
I want the Getting Started section breadcrumb, I want the current page title in the breadcrumb, but there is no page at /toolkit so I want to exclude that segment of the url.
How do you do this in the new version? I tried your code above and that did not help