Copy Paste Calendar

Summary: Adds a calendar to your wiki pages without installing any additional scripts
Version: 2016-12-24
Maintainer: StefCT
Licence: GPL
Users: +1 (view / edit)

Questions answered by this recipe

I'd like to include a calendar into my PmWiki pages, but I cannot (or do not want to) make any changes on my PmWiki server. How can I achieve this?

Description

Live Demo | View Markup


November 2024

Mon Tue Wed Thu Fri Sat Sun

01 Fri

02 Sat

03 Sun

04 Mon

05 Tue

06 Wed

07 Thu

08 Fri

09 Sat

10 Sun

11 Mon

12 Tue

13 Wed

14 Thu

15 Fri

16 Sat

17 Sun

18 Mon

19 Tue

20 Wed

21 Thu

22 Fri

23 Sat

24 Sun

25 Mon

26 Tue

27 Wed

28 Thu

29 Fri

30 Sat


Copy Paste Calendar can be included into nearly any PmWiki (with standard settings) by copying and pasting one single page of PmWiki markup. Custom CSS can be used to style the calendar. If desired, a separate PmWiki page will be generated for each day.

Note: This recipe has been tested with various PmWiki installations from version 2.2.50 onwards on different Linux servers as well as in different browsers. However I cannot guarantee that it will work properly in every environment imaginable. So please double check the calendar displayed with your personal calendar and please share your experiences in the talk page.

Unlike the first version, this one seems to work fine with most of the popular PmWiki skins. You can try Copy Paste Calendar with the skins of your choice here:

Choose skin:

Change skin permanently (using cookies):

How to Install

How to Use

  • Try browsing the calendar by changing the month and/or the year in the upper right corner
  • Click on a date to create an individual calendar page for that date which will be hosted in the same group as your calendar markup (name: yyyymmdd)
  • After creating and saving the page, the characters ">>" following the corresponding date in your calendar should indicate that a calendar page exists

How to Change the Layout

  • For a smaller calendar, change the (:include:) directive at the top of the page to:
(:include {$FullName}#smallerCalendar:)
  • For a tiny calendar with coloured fields, change the (:include:) directive at the top of the page to:
(:include {$FullName}#tinyCalendar:)
  • For a large calendar showing a summary of each calendar page, change the (:include:) directive at the top of the page to:
(:include {$FullName}#largeCalendarWithSummary:)

How to Include Your CopyPasteCalendar Into Other Pages

  • Your CopyPasteCalendar can be included into any page (no matter which group) by using an include directive like the one at the top of the source code
  • If you are hosting your calendar code at PLCalDemo.CopyPasteCalendar, you can include a large calendar into another PmWiki page with the following markup:
(:include PLCalDemo.CopyPasteCalendar#largeCalendar:)
  • All of the predefined layout options can be used this way, making it possible to display the same calendar with different layouts in various parts of the wiki

How to Customize Further

Important Notice

  • All the advanced code examples below can be included anywhere in your wiki (please swap out PLCalDemo.CopyPasteCalendar with the real name of the page hosting your calendar code)
  • If you want to add one of the code examples to the page hosting your CopyPasteCalendar code itself, please remove the (:include:) directive at the top of the page

Include Calendar for a Given Month

With the page list parameters ListYear={(ftime fmt="%Y")} ListMonth={(ftime fmt="%m")} a calendar for the current month is included. If you'd like to display a calendar for a given month instead, use ListYear=Year ListMonth=Month (please always use leading zeros/two digits for ListMonth and four digits for ListYear).

Calendar for January 2014
(:pagelist fmt=PLCalDemo.CopyPasteCalendar#calinclude \
name={$FullName} \
count=1 request=1 \
ListYear=2014 ListMonth=01:)

Apply settings to demo calendar

Custom Calendar Styles

With your page list directives you can include custom style definitions (they will override the default style settings):

Large Calendar
(:pagelist fmt=PLCalDemo.CopyPasteCalendar#calinclude \
name={$FullName} \
ListYear={(ftime fmt="%Y")} ListMonth={(ftime fmt="%m")} \
count=1 request=1 \
CalTableStyle="border-spacing:5px;width:600px; \
height:400px;" \
CalHeadStyle="text-align:left;padding-left:5px; \
border:1px solid silver;" \
CalBoxStyle="width:80px;height:80px;padding:5px; \
border:1px solid silver" \
CalEventCount=0:)

Apply settings to demo calendar

Smaller Calendar
(:pagelist fmt=PLCalDemo.CopyPasteCalendar#calinclude \
name={$FullName} \
ListYear={(ftime fmt="%Y")} ListMonth={(ftime fmt="%m")} \
count=1 request=1 \
CalStyle="width:460px;" \
CalTableStyle="border-spacing:5px;width:460px; \
height:380px;" \
CalHeadStyle="text-align:left;padding-left:5px; \
border:1px solid silver;height:25px;" \
CalBoxStyle="width:52px;height:52px;padding:3px; \
border:1px solid silver;" \
CalEventCount=0:)

Apply settings to demo calendar

Tiny Calendar with coloured fields
(:pagelist fmt=PLCalDemo.CopyPasteCalendar#calinclude \
name={$FullName} \
ListYear={(ftime fmt="%Y")} ListMonth={(ftime fmt="%m")} \
count=1 request=1 \
CalStyle="width:370px;" \
CalTableStyle="border-spacing:5px;width:370px; \
height:320px;" \
CalHeadStyle="text-align:left;padding-left:5px; \
border:1px solid silver;height:25px;" \
CalBoxStyle="width:40px;height:40px;padding:3px; \
border:1px solid silver; \
background-color:Gainsboro;font-size:10px;" \
CalEventCount=0:)

Apply settings to demo calendar

Custom Calendar Styles Explained

  • CalStyle: Used to define the size of the entire calendar section (including the dropdown menu/form at the top)
  • CalTableStyle: Used to style the table containing the calendar
  • CalHeadStyle: Used to style the boxes containing the weekday names
  • CalBoxStyle: Used to style the individual boxes for each day

For background information on how to use CSS style definitions in PmWiki please check out PmWiki.WikiStyles#styleclass.

Display Summary for Calendar Page

By default, your calendar will only display the characters ">>" to indicate that an individual calendar page exists for any given day. If you'd like to include some additional text, add a page text variable named Summary to your calendar page, e.g.:

Summary: Meeting

For displaying this summary in your calendar, you have two options:

  • use the predefined layout "#largeCalendarWithSummary"
  • add CalEventCount=1 to your page list directive, e.g.
(:pagelist fmt=PLCalDemo.CopyPasteCalendar#calinclude \
name={$FullName} \
count=1 request=1 \
ListYear={(ftime fmt="%Y")} ListMonth={(ftime fmt="%m")} \
CalEventCount=1:)

Apply settings to demo calendar (for January 2014)

Note: Please make sure that your calendar is big enough for the summary text to fit into the boxes by applying custom styles accordingly.

Start Week on Sunday

By default, weeks start on Monday in CopyPasteCalendar. If you want to change this, add CalStartWeek=Sun to your pagelist directive, e.g.

(:pagelist fmt=PLCalDemo.CopyPasteCalendar#calinclude \
name={$FullName} \
count=1 request=1 \
ListYear={(ftime fmt="%Y")} ListMonth={(ftime fmt="%m")} \
CalStartWeek=Sun:)

Apply settings to demo calendar

Localization

The calendar should respect your web server's current locale. If you aren't happy with the results (and you have access to your wiki server) try adding something like:

setlocale(LC_TIME, 'YourLocale');

to your local config, e.g.

setlocale(LC_TIME, 'de_DE.UTF-8');

for a German calendar (works only if the chosen locale is installed on the server).

Release Notes

  • 2014-01-09 alpha: Initial release
  • 2014-01-20 alpha: New version using a table instead of <div> containers for better compatibility with skins
  • 2014-02-02: Minor bugfixes/formatting changes, alpha state removed
  • 2014-04-23: name=Cookbook.CopyPasteCalendar added to page list directive for performance optimization (as suggested by VKrishn); GPL licence info added
  • 2016-12-24: Pre-defined layout options added (as suggested by VKrishn); documentation updated

See also

Contributors

StefCT

Comments

See discussion at CopyPasteCalendar-Talk

User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.