Printer-Friendly Calendar View
Calendar module is one of the most useful modules in Drupal. It allows to create and view different events in time. Equally important module is Printer-Friendly which allows to have Print link and formats page in a printer-friendly style.
Unfortunately, Printer-Friendly module only works with node pages and calendar views are Views module pages so printer-friendly does not work with them. Following is a quick tutorial (inspired by Chill35’s suggestion) on how to create printer-friendly pages for Calendar. Actually, the trick can be used for any views page, with some modifications.
The essence of the trick is that when we need a printer-friendly version of a page, we add “printit” to the end of the URL and when it is in the URL modify CSS accordingly to strip-off header/footer/etc. In Calendar module’s case (which is actually called “events”) you need to edit event_link() method in event.modules file.
In there, at the section where links are generated ( “elseif (user_access(‘access content’)) {“ section ) insert the following snippet:
-- snippet --
$curLink = $_SERVER["REQUEST_URI"];
// We gotta have full URl to do printer-friendly trick.
// If we do not have one, we gotta construct month view.
if ( !strpos ( $curLink, "all/")) {
$links['Printer-Friendly'] = l(t('Printer-Friendly'), $base .'month/'.
$node->filter.'/printit', array('title' => t('Printer-Friendly')));
}
if ( !strpos ( $curLink, "printme") && !$links['Printer-Friendly']) {
$links['Printer-Friendly'] = l(t('Printer-Friendly'),
$curLink."/printit", array('title' => t('Printer-Friendly')));
}
-- snippet --
This will add Printer-Friendly link to the links and only show it when you are not already in the printer-friendly mode.
Then in page.tpl.php of your Theme, in the head section, insert:
<?php
$curLink = $_SERVER["REQUEST_URI"];
if ( strpos ( $curLink, "printit")) {
print theme('stylesheet_import', base_path() .
path_to_theme() . '/print.css', 'all');
}
?>:
And the print.css file that you put in themes/ folder may look something like:
.header, .bar, .right_articles, .left_articles, .footer, .event-filter-control, .feed-icon {
display: none;
}