Add printer friendly style sheet on command
Adds a print.css style sheet to make your pages printer friendly when the pages url has the query ?print=1
Snippet:
Login/Register to Comment this Snippet<?php
//in template.php:
# get querystring for print friendly page
$cgi = $_SERVER['REQUEST_METHOD'] == 'GET' ? $_GET : $_POST;
foreach ($cgi as $key => $val) {
if ($key == 'print' && $val == '1') {
$styles = drupal_get_css(drupal_add_css(path_to_theme().'/css/print.css', 'theme', 'all', TRUE));
}
}
?><?php
//in node.tpl or page.tpl:
if (module_exists('path')){
$alias=drupal_get_path_alias($_GET['q']);
$id=explode('/',$alias);
}
?>
<a href="<?php print base_path().$alias.'?print=1'; ?>" title="Printer Friendly Page">Printer Friendly Page</a>