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 in print view

turns into:

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

reload - October 29, 2009 - 11:26

with code tags:

this link in print view :
<a href="#anchor">
turns into:
<a href="print/subdirectory/pagename#anchor">

#2

aasarava - October 30, 2009 - 16:59

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?

AttachmentSize
patch-print.pages_.inc-1.10-anchors.patch 565 bytes

#3

jcnventura - November 1, 2009 - 16:09
Status:active» fixed

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

System Message - November 15, 2009 - 16:10
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.