Controlling the Group Calendar with the Calendar Module

I have developed a patch to templates/modules/mod-calendar.tpl (for version 1.7.4) to allow you to control the focus date of the Group Calendar from the Calendar module.

Explanation of Code Change

The calendar module controls other aspects of Tikiwiki by adding day, mon, and year parameters to the Wiki page. Unfortunately, the group calendar is not amenable to control by these parameters. Instead, it expects a todate parameter, whose value is a Unix date (made with mktime()), rather than day, month and year numbers. This patch adds a todate parameter to the URLs produced by the calendar module.

It's a relatively simple patch of only a few lines.

Editorial comment: This is probably not the best way to achieve the objective. Ideally, there should probably be some uniform parameter structure imposed over the calendar and other wiki features so that a single set of calendar module parameters could be used by all of them. I was simply too timid to overhaul the tiki-calendar.php code to use day, mon, and year.

The patch

*** mod-calendar.tpl.orig       2003-12-18 16:26:51.000000000 -0600
--- mod-calendar.tpl    2003-12-19 11:22:49.000000000 -0600
*** 40,45 ****
--- 40,48 ----
+ // squash the todate, too, in case you're looking at the
+ // calendar. [2003/12/18:rpg]
+ unset($query["todate"]);
  if (count($query)>0) {
*** 61,66 ****
--- 64,70 ----
  } else {
+ $todaylink = $todaylink . "&todate=" .time();
  <div class="box">
  <div class="box-title" style="margin:0px;">{tr}Calendar{/tr}</div>
*** 122,127 ****
--- 126,135 ----
                print( "<td class=\"fc\" align=\"center\">" );
                $url = $father."day=$pval&amp;mon=$mon&amp;year=$year";
+               // now add a timestamp todo argument to the query so that
+               // a calendar page can be navigated. [2003/12/19:rpg]
+               $rpgtime=mktime(12, 0, 0, $mon, $pval, $year);
+             $url = $url . "&amp;todate=$rpgtime";
                print( "<a class=\"$classval\" href=\"$url\">$val</a></td>");

Page last modified on Friday 19 December 2003 21:07:15 GMT-0000