CSS for custom templates

gmak - October 19, 2009 - 12:25
Project:Printer, e-mail and PDF versions
Version:6.x-1.9
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

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

#1

jcnventura - October 19, 2009 - 14:55
Status:active» postponed (maintainer needs more info)

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

gmak - October 19, 2009 - 15:14

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

jcnventura - October 19, 2009 - 15:24

What's the value of the type parameter in the drupal_add_css() call?

#4

gmak - October 19, 2009 - 20:59

there is no specified 'type' parameter in my call to drupal_add_css():

drupal_add_css(path_to_theme() .'/node-assessment.css');

#5

jcnventura - October 19, 2009 - 21:50

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:

<?php
drupal_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

gmak - October 19, 2009 - 22:50

Thanks again, for yoru help.

Let me check if I've understood this correctly:

At the top of print.tpl.php, I should add:

<?php
drupal_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

jcnventura - October 22, 2009 - 10:22

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

jcnventura - November 9, 2009 - 11:41
Status:postponed (maintainer needs more info)» closed

No further info in two weeks. Closing the issue.

 
 

Drupal is a registered trademark of Dries Buytaert.