Hi,
I've noticed an issue when the breadcrumb trail is built that it is not including any paths that have changed and the redirect module has put a redirect in place.
I'm not sure where the fix for this lies, but I thought I would document here and see where we go from there.
First off you'll need the redirect and the pathauto modules installed. For the pauthauto module settings you'll need to set [node:menu-link:parents:join-path]/[node:title]in /admin/config/search/path/patterns as the default pattern for all content.
Steps to re-produce:
- Create a piece of content (pathauto should give it an alias)
- Place it in the menu (top level is fine)
- Create another piece of content and place it in the menu as a child of the above content
- Navigate to the child page and see the parent page in the URL path and in the breadcrumb
- Now edit the parent page and change the title - This will re-generate a new alias and create a redirect
- Re-visit the child page and note the URL path is still the same and that the parent page has dropped out of the breadcrumb
Example:
- Page: /leader-different-content-types is in the top level of the menu
- This page has had its title changed at some point
- Child page: leader-content-types/demo-content-leader-page/test-page-2 has the old path in its URL (which is setup as a redirect to: /leader-different-content-types)
- Re-generating the URL aliases for all site content doesn't update the child URL as pathauto is happy with it.
- A re-save of the child page doesn't update the URL alias either
So if pathauto is happy with the URL not to change for the child, should easy breadcrumb try and lookup redirects in the alias?
I'd love to hear someone elses thoughts on this.
Cheers
Tom
Comments
Comment #2
greg boggsI'm with you. My first thought is that you should update the child page URL when changing the parent page URL. However, if we can come up with a reasonable solution that supports redirects, that sounds pretty darned cool to me...
~G
Comment #3
blacklabel_tom commentedHi,
I've added a VERY hacky patch to show how this could work. Is there a way to optionally add services via DI? That would be a much better way to get the RedirectRepositry that I'm using to look up the redirects.
Again the root cause for this is that when a URL alias is updated it isn't aware of the child nodes it needs to update too. This patch just attempts to treat the symptom when it gets down to easy breadcrumb.
Cheers
Tom
Comment #4
blacklabel_tom commentedComment #5
tim-dielsI'm experiencing the same problem but in a slightly different context.
Our pathauto settings are the same as the reporter of the issue.
We allow to change the menu title and so the url alias is different.
Default menu title:
Changed menu title:
Patch #3 works for us as expected.
Patch #4 doesn't work for us as it adds both a plain text segment and the linked segment.
Comment #6
tim-dielsAt the end the patches don't work in our situation. If the menu title for the parent node is changed, and there is no redirect, the beadcrumb fails.
I ended up using a different token: [node:menu-link:parent:url:path]/[node:title]
Comment #7
blacklabel_tom commentedNew patch as the old one was causing duplicates on the site I'm working on. This is purely for me so I can keep the module patched with composer.
Comment #8
blacklabel_tom commentedComment #9
feng-shui commentedI've taken a different approach to get this in, dropping a block code in `getRequestForPath()` which checks if the path is a redirect, and if it is, resolving it to its source before the request object does it's thing.
Comment #10
greg boggsThis patch needs a reroll but is otherwise ready to go.
Comment #11
greg boggsComment #12
feng-shui commentedReroll.
Comment #13
greg boggsWe need to add an empty updb to cache clear since this patch changes the services.
Comment #14
feng-shui commentedAdded update hook.
Comment #15
feng-shui commentedComment #16
greg boggsComment #17
basvredeling+1 for #14
Comment #19
neslee canil pintoCommitted, Thanks Everyone.