I'm using CustomCSSJS version 1.5/dev together with "Printer-friendly pages" (Printer, e-mail and PDF versions v1.10: http://drupal.org/project/print). Loading the print version doesn't include the custom css files. Many other css-files are loaded as well, so I think this might rather be a bug in CustomCSSJS than in the print module.

I would appreciate if my custom css files would be included in the print version too. Even if there is a possibility to manually attach a (single!) css file to the printed version via administration interface, this would be in opposite to the intention of this module.

Comments

davebv’s picture

drupal_add_css includes by default in all media, I will have a deeper look into this.

x-lette’s picture

Thanks in advance!

sirprize’s picture

Edit: Sorry, I misunderstood the problem. My proposed solution (which can still be seen below) does NOT work on printer-friendly pages (like I hoped it would), only while printing a normal ("non-printer-friendly") page. Perhaps I will get a chance to investigate this in the next few days, since I also would like this to work. I'm leaving the code snippet though because it could still prove useful.

Old posting
I had a similar requirement, which I fixed in a quick&dirty way. If the filename contains "print", the media is set to print. If it contains "screen", the media is set to screen. Else, the media is all.
To achieve that, I changed the code of the callback function to this:

function _customcssjs_add_css($filename) {
  $media = 'all';
  if(strpos($filename, 'print')!==FALSE)
    $media = 'print';
  if(strpos($filename, 'screen')!==FALSE)
    $media = 'screen';
  drupal_add_css($filename, 'theme', $media) ;
}

I did not make a patch out of it because there is probably a better possibility to achieve different media types. Also, the argument list of drupal_add_css will change in D7, making an adjustment necessary.

Anyway, feel free to include or ignore this code snippet. I hope it will be useful for some :)

davebv’s picture

Status: Active » Closed (fixed)

open it again if necessary