Add 'Print-friendly' support for a calendar
Required
Print Module > http://drupal.org/project/print
Event Module > http://drupal.org/project/event
The excellent Print Friendly Pages module
http://drupal.org/project/print
does an excellent job on producing nicely formatted output suitable for printing.
However, as the 'Month-view' calendar produced by the events module
http://drupal.org/project/event
isn't actually a node, no 'printer friendly version' link appears.
Here's how to achieve this:
First thing, create a page using this code
<?php
print event_page($year = NULL, $month = NULL, $day = NULL, $view = NULL, $types = NULL, $tids = NULL, $duration = NULL)
?>Make sure to use PHP as the input type.
This should output the calendar within a node, with the requisite 'printer friendly version' link appearing at the bottom.
Advanced Usage
Create a new menu item, that links directly to the 'print-friendly version'. EG http://example.com/node/123/print.
Create a new menu, and place this menu item as the sole item within in.
Go to 'administer > blocks'.
Enable the block for the new menu.
Configure the 'block visibilty', and set it only to appear on the Event page.
Slightly More Advanced Usage
Place the block in the 'content' region [This does not exist in all themes!]
The new block will appear below the calendar, more or less the same as a standard 'printer friendly version' link!
For Bonus Points:
Ammend the Print module to include event.css file.
By default, the print module will not include the CSS files that make the event calendar 'pretty'.
Open the print.node.tpl.php file within the print module folder.
Add this line
<style type="text/css">
@import url(<?php print $base_path . drupal_get_path('module', 'event') .'/event.css';?>);
</style> below the
<style type="text/css">
@import url(<?php print $node->printcss; ?>);
</style>This will add the event.css file to the print-friendly version pages.

can you do it w/ a custom views page?
great adaptation! i would like to be able to do the same with a custom calendar view. replacing the
event_pagewith the name of the view, or various permutations like that does not seem to be doing the trick. where/what should i try?thanks! isaac
Different, more flexible (?) solution
With the above solution, you can only print the current calendar (or whatever code is permanently written into that node page).
I've found an alternative solution, based on the fact that *any* page URL - if preceded by "print/" - will render in the print format. In looking for good solutions to pull the URL then modify it, I actually went back to the Print module, and pulled several lines. This turned out to be the best solution, because this code also pays attention to how you have set up your print module.
I took these lines below and put them into a block that appears below the content. In block visibility I have selected "event" and "event/*".
I now have a link for every calendar page / style (table, list, day) that renders in print format.
if ($path === NULL) {$path = PRINT_PATH .'/'. preg_replace('!^node/!', '', $_GET['q']);
$query = print_query_string_encode($_GET, array('q'));
if (empty($query)) {
$query = NULL;
}
}
$format = theme('print_format_link');
return '<span class="print">'. l($format['text'], $path, $format['attributes'], $query, NULL, TRUE, $format['html']) .'</span>';
undefined function
Call to undefined function print_query_string_encode() in /includes/common.inc(1355) : eval()'d code on line 4
drupal 5.12
changed to drupal_query_string_encode()
also changed PRINT_PATH to 'print'
(print module must be installed)
this is a nice solution. it might be good to add some css that hides the select boxes for filtering, and this block should ship with the event module.