I am using drupal 6 and in my theme.info file I have the following:

stylesheets[print][] = print.css

I also have the following in the print.css file:

h1 {
color: grey;
}

but when someone clicks on the "printer-friendly version" link it acts like it is ignoring the print.css file alltogether.

I noticed in the source of the print page that it is referencing misc/print.css. I tried to add the h1 section to that one as well and the results are still the same. It is basically ignoring the print.css file all together.

Can someone point me in the right direction of where I need to look to see what is going wrong here?

Comments

vm’s picture

have you tried clearing the cache ?

administer -> performance

Anonymous’s picture

I did try that and it had no effect.

matkeane’s picture

I should start by saying that I have barely played with D6, so take all this with a pinch of salt...

Normally, print style sheets are only referenced by the browser when a page is actually printed - that is, you hit the print button - at which point the browser re-renders the page using the print style sheets in addition to any other style rules that apply (ones where the media attribute is 'print' or 'all').

I'm guessing that the 'printer friendly version' link uses a modified style sheet (removing unnecessary navigation elements, etc) for the browser screen display so that the page prints out more nicely, but you are basically navigating to a simplified on-screen page. Again, the print.css style sheet won't be called until you actually hit print so you won't see your print styles on-screen (but you can do a print preview to check).

If you set rules in your print.css to hide navigation menus etc, you might not really need the 'printer friendly pages' anyway, unless you need to transform the layout more than can be achieved by CSS rules.

But, like I say, without much D6 experience, I might be talking rubbish here!

tnanek’s picture

I'm having the same problem. But I also have a feeling as to why it's not working (in my case anyway).

I'm using the book module's Printer Friendly Version in Drupal 6. When I view the resulting page's source, it has the line:
<link type="text/css" rel="stylesheet" href="misc/print.css" />
So that avoids the cache problem on the drupal side of things - browser cache might be an issue, but disregarding that...

My site is installed in a sub-domain. Further up on that page's source, I some similar lines being:

  <!--[if IE]>
  <script type="text/javascript" src="/sa/misc/jquery.js"></script>
  <script type="text/javascript" src="/sa/misc/drupal.js"></script>
  <script type="text/javascript" src="/sa/sites/all/modules/nice_menus/nice_menus.js"></script>
  <![endif]-->

and ironically enough, my subdomain is sa.

So now I ask, how would I change the address that Drupal is indicating for the print.css file from "misc/print.css" to "/sa/misc/print.css" since I have a gut feeling that would work.

---
EDIT
I got it to work after correcting the subdomain issue on my site, now www.domain.com points to the directory where /sa was getting it, so now I have no problem.

mcm.drupal’s picture

The Printer Friendly page in my (outdated) 6.8 contains:

  • A base href with NO TRAILING slash
  • A link href with NO LEADING slash for "misc/print.css"

When concatenated to form the address of the stylesheet, they give an illegal url containing "http://mydomain.commisc/print.css".

So I believe it's the leading slash, not the existence of a subdomain, that fixed the above problem.

I think this is a bug, which may be fixed in the current version... I hesitate to file a bug report since I'm not sure it hasn't been reported... and I've never done so before :-(