Posted by gmak on October 19, 2009 at 12:25pm
Jump to:
| Project: | Printer, e-mail and PDF versions |
| Version: | 6.x-1.9 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
I've managed to get the module to use my custom template files (sort of), but I'm having a little trouble getting the related CSS to be included. So a few questions...
Does the module allow for drupal_add_css or must you explicitly reference your css file?
Do I need to include the @media definition within the CSS file?
Thanks
Comments
#1
If 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
#2
Joã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?
#3
What's the value of the type parameter in the drupal_add_css() call?
#4
there is no specified 'type' parameter in my call to drupal_add_css():
drupal_add_css(path_to_theme() .'/node-assessment.css');#5
If 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:
<?phpdrupal_add_css(path_to_theme() .'/node-assessment.css');
$print['scripts'] = drupal_add_css()
?>
This should include your CSS in the current CSS list.
João
#6
Thanks again, for yoru help.
Let me check if I've understood this correctly:
At the top of print.tpl.php, I should add:
<?phpdrupal_add_css(path_to_theme() .'/node-assessment.css');
$print['scripts'] = drupal_add_css()
?>
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?
#7
Sorry,
The second line, obviously should be like this:
<?php$print['css'] = drupal_add_css();
?>
I copied the wrong part of the template file, and didn't check the code so well..
#8
No further info in two weeks. Closing the issue.
#9
Proposed 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:
<?php
drupal_add_css(path_to_theme() .'/print-newcss.css');
$print['css'] = drupal_add_css();
?>
I also moved this file to my custom theme folder (sites/all/theme/custom_theme).
Any suggestions?
Thanks for the VERY useful module!
#10
#11
You'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.
#12
No further info in more than two weeks. Closing the issue.