The URL for my page is:

http://www.website.com/beta/node/6

but the Printer-friendly page lists it at the bottom as:

http://www.website.com/beta//beta/node/6

(it adds the "/beta" twice with an extra "/")

Drupal's root is installed at www.website.com/beta. The settings.php file does NOT have a trailing "/". I am running 4.7 beta 5

Comments

deekayen’s picture

Status: Active » Fixed

Fixed in HEAD and DRUPAL-4-7. I think it was related to the BASE tag being removed for 4.7, so I'm guessing they added a / to the output of url().

Anonymous’s picture

Status: Fixed » Closed (fixed)
davereplicant’s picture

Version: » 4.7.x-1.x-dev
Assigned: Unassigned » davereplicant
Status: Closed (fixed) » Active

I'm experiencing this too!

Drupal. 4.7.2
print.module,v 1.6.2.7

I have Source URL:
http://website.co.uk/beta/beta/page instead of http://website.co.uk/beta/page displaying at the bottom of my printer friendly pages.

Is there a little bit of code i need to change in order to fix this?

I'm a bit of a newbie so sorry i can't be of more help.

Thanks in advance.

dizwell’s picture

I hesitate to add this, because I am certainly not a PHP developer and my programming skills are barely non-existent. But I was desperate, and suffering from the same problem as the other posters here: what should appear on a printer friendly page as, for example,

http://www.dizwell.com/prod/node/4

...would actually appear as...

http://www.dizwell.com/prod/prod/node/4 <-with the "prod" bit duplicated

...and this is despite me using the latest version of PFP with Drupal 4.7.

Anyway, I brute-forced the fix by editing the /prod/modules/print/print.node.tpl.php file. Originally, this crucial bit of the file read:

print '<strong>'.t('Source URL:').'</strong><br /><a href="'.$node->source_url.'">'.$node->source_url.'</a>'

I changed that to read:

$base1=substr("$node->source_url",0,28)
$page1=substr("$node->source_url",33,99)
$correct_url=$base1.$page1
print '<strong>'.t('Source URL:').'</strong><br /><a href="'.$correct_url.'">'.$correct_url.'</a>'

The numbers in there only work for me: the full URL "http://www.dizwell.com/prod/node/X" has 28 characters before the "prod" repeat, and then I skip 5 characters ("prod/"), and then pick up the rest of the URL as a second string. The third line concatenates the two partial strings back together, and sets the display text and href code to be that new concatenation. If your base directory is "production" instead of "prod", for example, then you'd have to skip 11, not 5 characters... and if your domain name was www.fred.com, your first set of numbers would be more like '0 to 30'. Hopefully, you get the idea.

It's horrible, it's flakey, I'm sure there are nicer ways of doing it, and Lord knows if it breaks anything else (but my site's working nicely). I stand prepared to be roasted for being so inept, but I was desperate, and others might be too, so I thought I'd just mention it... and also point out that this issue is not yet fixed.

dizwell’s picture

Sorry. The inclusion of bits of php code in my last reply kind of screwed with the formatting of my last comments.

That should have read "I edited /modules/print/print.node.tpl.php"

And the bit I edited was the bit inside the "div class equals source URL" section. The first block of code in my original note above was what I changed. The four subsequent blocks of code shown above were simply four new lines to replace that first one with.

basicmagic.net’s picture

hello and thanks-

i had this same problem too-
but i fixed it a different way- using some insight gained at the following post:

http://drupal.org/node/52611

what i did was, take some of the code in the patch supplied for the single sign-on module-
thanks very much to dotan!

and adapted it to the print.module to fix the source url on printer friendly pages.

then i simply pasted this new code, (below)-
into the bottom of print.module-

and then also changed this line, from:

$node->source_url = $base_url . url("node/$node->nid");

to:

$node->source_url = print_source_url() . url("node/$node->nid");

seems to work pretty good-
across a bunch of sites, regular drupal installs-
and multi-sites as well.

and most of my sites have base urls like:

http://www.domain.com/web

here is the code to add to print.module-
don't please don't forget to change the line above as well.

 /**
 * Concat the base url without duplicating the path
 */

function print_source_url() {
  global $base_url;
  $base_url_no_path = $base_url;
  if (preg_match("@^https?://[^/]+@i", $base_url, $base_url_matches)) {
    $base_url_no_path = $base_url_matches[0];
  }
  return $base_url_no_path;
}
jcnventura’s picture

Status: Active » Closed (fixed)

This is now been fixed in the latest 5.x dev release.