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?

dotist - October 22, 2007 - 16:26

great adaptation! i would like to be able to do the same with a custom calendar view. replacing the event_page with 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

 
 

Drupal is a registered trademark of Dries Buytaert.