Closed (fixed)
Project:
Printer, email and PDF versions
Version:
6.x-1.9
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
19 Oct 2009 at 12:25 UTC
Updated:
31 Jul 2010 at 00:38 UTC
Jump to comment: Most recent
Comments
Comment #1
jcnventuraIf you call drupal_add_css() in the original node, that CSS will be used in the print output, as long as the type parameter is not set to 'theme'.
You don't need the @media.. Since the module creates a paper-suitable display in the default setting, there's no need to specify different medias.
João
Comment #2
gmak commentedJoão,
Thanks for the quick response. My original template does call drupal_add_css(), but the custom print template does not seem to be getting the correct css.
Both templates are in my theme folder. For example, I have:
node-assessment.tpl.php which calls node-assessment.css
for printing, I have:
print_html.node-assessment.tpl.php (this file does not include the drupal_add_css call).
But, I get the overall template structure, but none of the styles from node-assessment.css.
Any suggestions?
Comment #3
jcnventuraWhat's the value of the type parameter in the drupal_add_css() call?
Comment #4
gmak commentedthere is no specified 'type' parameter in my call to drupal_add_css():
drupal_add_css(path_to_theme() .'/node-assessment.css');Comment #5
jcnventuraIf nothing is specified, it is type = 'module'.
However, reading it again, I would like to point out that your template file is not used by this module, so whatever PHP you do in it needs to be duplicated in the print.tpl.php file. Specifically, you need to add to write the following at the top of the file:
This should include your CSS in the current CSS list.
João
Comment #6
gmak commentedThanks again, for yoru help.
Let me check if I've understood this correctly:
At the top of print.tpl.php, I should add:
Yes?
If that is correct, then something is not working because the css does not get applied to print output.
However, if I manually add my css to the print.css file, then it gets applied to print output/pdf. I don't like this as a solution, because it means I have to edit multiple files when I need to change some css.
Is there something else I've not got right?
Comment #7
jcnventuraSorry,
The second line, obviously should be like this:
I copied the wrong part of the template file, and didn't check the code so well..
Comment #8
jcnventuraNo further info in two weeks. Closing the issue.
Comment #9
kay_v commentedProposed solution doesn't work for me: I get the word "array" at the top of the body.
Here's what I put at the very top of the print.tpl.php file:
I also moved this file to my custom theme folder (sites/all/theme/custom_theme).
Any suggestions?
Thanks for the VERY useful module!
Comment #10
kay_v commentedComment #11
jcnventuraYou're right, this doesn't work at all. You have to add the proper html to include a css file:
<link type="text/css" rel="stylesheet" media="all" href="path to css file" />just below the $print['css'] line.
Sorry for the above suggestions, I only tired it myself now.
Comment #12
jcnventuraNo further info in more than two weeks. Closing the issue.
Comment #13
jlyon commentedI was trying to do this in a theme preprocess function, and it took me far too long to figure out, so here's the code. I hope it helps someone out. This added a lot of the CSS from my theme, but in my case that was actually a good thing.
/*** Implements hook_preprocess_print()
*/
function hopelink_preprocess_print(&$vars) {
drupal_add_css(path_to_theme() . '/css/print.css');
$vars['print']['css'] .= drupal_get_css();
}