Problem/Motivation
If in Path breadcrumbs settings the option:
“Use module breadcrumbs render function” is checked
All the links get broken this way:
localhost/sandbox/test/mydrupal/sandbox/test/mydrupal/admin/config
localhost/sandbox/test/mydrupal/sandbox/test/mydrupal/node/3
www.example.com/subdirectory/mydrupal/subdirectory/mydrupal/about-us
etc.
I have tested on localhost and on the server with path_breadcrumbs module versions:
7.x-2.0-beta17
7.x-3.x-dev
Drupal versions:
7.18, 7.19
Related Issues
It is similar to the issue http://drupal.org/node/1645110 (link to homepage when my drupal not in root folder of server) but unlike it, it does not happen when the link points to , in fact that is the link that does not get broken.
The solution for this issue (#14) is no longer applicable for current versions.
Proposed resolution
After some inquires and tests on the module, I spotted that in the path_breadcrumbs.module the call to the l() function uses as argument not an internal path, (admin/config, node/3 etc.), but:
sandbox/test/mydrupal/admin/config
sandbox/test/mydrupal/node/3
One can argue that if you change the Base URL in the settings.php file, it could be resolved, but when the “Use module breadcrumbs render function” is unchecked it works as normally. Also it could be discussed that subdirectories should not be included in the internal path.
So I spotted this line in the path_breadcrumbs.module, (approximately in line 278 in 7.x-2.0-beta17 and line 318 in 7.x-3.x-dev)
function path_breadcrumbs_breadcrumb($variables) {
...
else {
// HREF param can't starts with '/'.
$href = stripos($matches[1], '/') === 0 ? drupal_substr($matches[1], 1) : $matches[1];
}
Then I substituted 1 with drupal_strlen($base_path)
else {
// HREF param can't starts with '/'.
$href = stripos($matches[1], '/') === 0 ? drupal_substr($matches[1], drupal_strlen($base_path)) : $matches[1];
}
It solves the problem for me, anyway I would like to know if other people have the same problem.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | path_breadcrumbs-1893878-10.patch | 2.14 KB | OnkelTem |
Comments
Comment #1
sakseiw commentedI have Same problem.
Proposed solution works for me too.
Comment #2
Anthony Goode commentedHi sakseiw,
Thank you for your feedback!
Comment #3
spleshkaStill can't reproduce it. Can you provide some tests for that?
Comment #4
Anthony Goode commentedI reproduced it with a new installation of Drupal 7.20 from scratch (standard and only English).
The url of the drupal site test was: localhost/drupal/dummysites/drupal720
After that I installed and enabled the following modules:
It worked well until I used localization update to download the .po files of a new language (in my case Spanish). Then it does not matter which language is set as default, after that if you click on a breadcrumb link an error saying that Page not found appears.
E.g.:
Page not found
The requested page "/drupal/dummysites/drupal720/drupal/dummysites/drupal720/admin/config" could not be found.
Then if I change the line 278 in the path_breadcrumbs.module file as I posted before (see proposed solution), links work well again.
If you can not reproduce the error, please let me know.
Thanks for your interest in investigating the error!
I also want to congratulate you for your great work in the developing and maintenance of this module, for me it is simple to use, powerful and so the best dealing with breadcrumbs.
Comment #5
spleshkaThanks for your report :) But this is not "Quick fix." I have to dig dipper and try to understand why problem occurs and avoid similar bugs in the future.
Comment #6
kalabroGuys, that was really difficult to reproduce!
I finally found it when:
nodefor example).First commit is here: http://drupalcode.org/project/path_breadcrumbs.git/commitdiff/91f1307cec...
Please, test if it fixes your problem. Thanks!
May be related:
#1998096: Path breadcrumbs leads to a "Page not found" even when in Administration
#1949866: Wrong breadcrumb link with url prefix.
Comment #7
HakS commentedI had same problem,
#6 worked for me, thank you @kalabro
Comment #8
kalabroSould be fixed in 7.x-3.0-beta4 release.
Comment #10
OnkelTem commentedThis is new patch which make PB behave more like core l() function when working with languages, taking into account real URL language, rather then UI language ($langauge_url vs $language).
Comment #12
kalabroThank you @OnkelTem! It will be in PB 3.1 release.