Print view breaks link anchors
reload - October 29, 2009 - 11:23
| Project: | Printer, e-mail and PDF versions |
| Version: | 6.x-1.10 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Hello,
Regarding print view - link anchors borken
This link does not work because you are already in the subdirectory.
The 404 page would be:
/subdirectory/print/subdirectory/pagename#anchor
Any ideas would be helpful.
Thanks!

#1
with code tags:
this link in print view :
<a href="#anchor">turns into:
<a href="print/subdirectory/pagename#anchor">#2
We're having the same problem. I'm attaching the patch for print.pages.inc (version 6.x-1.10) that should hopefully fix it. It's a simple one:
Change line 396 from:
<?php$matches[1] = str_replace($url, $_GET['q'] . $url, $matches[1]);
?>
to:
<?php$matches[1] = str_replace($url, '/' . $_GET['q'] . $url, $matches[1]);
?>
Be sure to check all your other links to make sure this doesn't mess anything else up. Can the maintainers or someone more familiar with the code weigh in on whether this is an appropriate fix?
#3
Indeed, the path needs to be made absolute so that anchors in pages in non-root paths still work.. However the patch in #2 fails in Drupal sites which are installed in a sub-path of the server's document root, instead of '/' it needs to be base_path().
I have committed a patch that fixes this to CVS.
#4
Automatically closed -- issue fixed for 2 weeks with no activity.