Summary: Talk page for the PmCalendar recipe
Format: unless and until the content is refactored by topic, let's Add New Material At the Bottom - below previous entries.

Calendar on any page of any wikigroup

In-wiki admin

I like to set up my wikis so that wherever possible, features can be added, configured and administered from within the wiki, without requiring any server-side work other than to add and enable a recipe.

Default setup

To quote Chris Cox, author of this wonderful recipe: "The PmCalendar is designed assuming that it will be placed into its own group and the location of the [ (:pmcal:) ] markup inside of the GroupHeader or GroupFooter of the group...the Calendar will show up as part of the GroupFooter (for example) on any page contained within the Calendar group (or whatever group it's setup in)." To format the calendar, a copy of the PmCal.css file is renamed to the name of the wikigroup and placed in pub/css/ directory.

Any page of any wikigroup

I want my users to be able use the calendar in any wikigroup they like, without needing to have an administrator install the PmCal.css file. I find that Chris's default design for the appearance of the calendar is clean, simple, and more than adequate for most purposes. What's more, I've found that a calendar does not have to be installed in its own wikigroup. While the limitation of one calendar per wikigroup does remain, within a multi-purpose wikigroup one can display that wikigroup's calendar by placing the (:pmcal:) markup on any chosen page(s) - the group's Group.HomePage or Group.Group And/Or a Group.Calendar page. Used this way, though, the recipe does need a couple of adjustments to work.

Tweaks to make it work

Re-code four links

As downloaded, there are four links that appear above each calendar that will not operate properly unless the calendar is displayed on the wikigroup's default page Group.Group or Group.HomePage: The "Today" link and the navigation links to the previous, currently displayed and next months' views. I customized the code for these links in my installed version of the recipe, and don't see any drawback to using this altered version in any application of the recipe - i.e., I think you can do this, too, without any adverse results (But I'm not positive, which is one reason I created this "Talk" page).

Here's the tweak. Replace $group with $name in four places.

Change the three here:
$out.="[[$group?month=$prevmonth&day=1&year=$prevyear$urladd|$navprevout]] %%";
$out.="%class='pmcalnavlinks pmcalnavlinksnext'%";
$out.=" [[$group?month=$nextmonth&day=1&year=$nextyear$urladd|$navnextout]]%%\n";
$out.="[[$name?month=$prevmonth&day=1&year=$prevyear$urladd|$navprevout]] %%";
$out.="%class='pmcalnavlinks pmcalnavlinksnext'%";
$out.=" [[$name?month=$nextmonth&day=1&year=$nextyear$urladd|$navnextout]]%%\n";

And change this one:


Navigation help

Here's a usability tweak. Since it seems likely that someone reading a date-page will want to return to the calendar's display page (and since in this type of implementation, the (:pmcal:) markup isn't in the wikigroup's header or footer to provide easy navigation), you may want to add to the group header some conditional code that will display a link back to the Calendar page at the top of every date-page. You might want something that would provide, in essence, (:if name YYYYMMDD:)''[[Group.Calendarpage | Back to Calendar]]''(:if:). PM provided the code for this:

To approach (:if name YYYYMMDD:) use

  1. (:if match \.\d{8}$ :) which matches only pages that have a name consisting of exactly eight digits, or
  2. (:if match \.200\d{5}$ :) which requires that the first three digits are '200', or
  3. (:if match \.20\d{6}$ :) which requires that the first twp digits are '20'.

I welcome questions or suggestions for any part of this variant. -- TeganDowling

More than one entry per day plus use of form?

I would like come up with a way to turn the entering of information for each day into a more "appointment like" process that includes a form with required entries. Three entries that could be used for the entry on the main calendar page might be start time, end time and name of the event. Then you could have additional entries for that event/appointment with various validation criteria. Each individual event could have its own "clickable" link.

Any pointers for where to start (I may ask you this in person on Saturday...)? -- Rick Cook

ccox Creating a wiki page is pretty simple... and it would be possible using PmWiki's forms to gather info and create the page. The level on exact integration into PmCalendar... unknown. Might not be terribly hard to do. Certainly things on the plate for PmCalendar 2.0... at least I'm looking into it (no promises). The iCal Export recipe could be used to extract entries of a particular format for easy importing into whatever iCal capable tool you might have. Might want to look at that for some ideas of how the data might be formatted inside the created page.

Event categories / multiple calendars

I have a wiki which is used by multiple groups of people. I wonder if it is possible to have a calender which is used by group A, a calender used by group B, and a calendar for common events. Ideally, each calendar would be placed in his/her own group, and you can easily select (:pmcal groups="CalendarA,Common":) to select events from multiple categories.

Birthdays, etc. from page text variables?

I have been wanting to use my wiki to store contact information, including information like birthdays, and somehow have that appear on a calendar. The FoxContacts recipe could easily be adapted to include birthdays, anniversaries, etc., but these are stored as page text variables in pages organized by person. Not quite what this recipe wants as input. Of course we could probably modify FoxContacts to add birthdays directly to the appropriate calendar page -- but then when we discover we have to correct some dates, we end up with our contact pages and calendar pages out of sync.

Looking over the PmCal code, I see it loops over cals and acals -- how difficult would it be to also check an array that some escape function might have preloaded with calendar information? The escape might be able to loop over a group, checking page text variables and loading the array. This escape should be called once -- you don't want to loop over perhaps hundreds of contact for each date displayed. (You could probably have other escape functions that look at ical information, event databases, etc.) Sorry that I am not a PHP hacker, or I'd attempt this myself. -- rlt

Displaying calendar from todays date

I may have missed this, but how do you display calendar events from todays date onwards?

I have a sidebar which displays upcoming events. When I view or edit a calendar page from a month in the future, the sidebar also displays from that month onwards. I want it to display from the current (real world) date.

I'm currently using: (:pmcal cals=PmCal caltype=text expire=true textdatefmt='%d.%m.%y' monthsahead=1 reverse=false:)

Is there a call along the lines of startdate=today? -- Garth

ccox Try alwaystoday=true in the sidebar calendar markup.

Holiday button/link appearing in wrong color

There appears to be a small bug in PmCal.php causing this link to not use its proper class. I fixed it by changing:

	// Output Extra Included Calendars links
	$cl=sprintf("${PmCalPrefix}include%slink pmcalincludelink",$cal);
	foreach ($cals as $cal) {
		if ($cal != '') {

To this:

	// Output Extra Included Calendars links
	foreach ($cals as $cal) {
		$cl=sprintf("${PmCalPrefix}include%slink pmcalincludelink",$cal);
		if ($cal != '') {

...which makes sense, since $cal is set within the loop! I'm not certain this is right, but it worked for me.

Hi, Is it possible to make new pages from pmcalendar to open generated and saved? Using template?


I thought I'd share some calendar-related code that I use to highlight my Calendar link in my SideBar. The link turns red when something is on the calendar for today, or green when something is on the Holiday calendar for today. This is a calendar that does NOT have events every day or this would be pretty useless.

Modify local/config.php to add the following lines:

# for Pm Calendar
# define yyyymmdd and mmdd page variables for calendar page referencing
$FmtPV['$yyyymmdd'] = "strftime('%Y%m%d',$Now)";
$FmtPV['$mmdd'] = "strftime('%m%d',$Now)";

Modify Site.SideBar to have a link to the your calendar group (adjust your group name as necessary):

(:if exists MyCalendar.{$yyyymmdd}:)
* %red% [[My Calendar/]] %%
(:elseif exists Holidays.ACAL{$mmdd}:)
* %green% [[My Calendar/]] %%
* [[My Calendar/]]

Scott Connard

Problem after php upgrade.

I use xampp as the basis for my server (yes, I make it secure), and just did an upgrade. I now get a very ugly error:

Deprecated: Function ereg() is deprecated in [my root path]\xampplite\htdocs\wiki\cookbook\pmcal.php on line 297

is repeated about 20 times, then:

Warning: Cannot modify header information - headers already sent by (output started at [my root path]\xampplite\htdocs\wiki\cookbook\pmcal.php:297) in [my root path]\xampplite\htdocs\wiki\index.php on line 1084

shows up.

xampp lite is now using php version 5.3.0 -- any ideas for a fix, or at least suppressing error reporting?


ccox Replace the one ereg call in pmcal.php with preg_match.

Thanks. I don't know what's worse: PHP playing these games, or the alternatives to PHP. The command is around line 297.

Also, one must add the ending delimiter now so that the expression "^[0-9]+$", "$y" becomes ^[0-9]+$^", "$y


Hi, is it possible, to increase the fontsize of the dataentries? I am using
(:pmcal styles=PmCal weekstart=1 dayofweektitlefmt=%A acals=Kal expire=false:)
I tried to specify something in the cssfile at td.pmcaltoday and td.pmcalday but it does take no effect.

I so much wait

this recipe to get updated for PHP 5.5. please, please, please !


Talk page for the PmCalendar recipe (users).