PagelistCalendar

Summary:Use PageTextVariables and ftime markup expression to create a calendar where each event has its own page.
Version:
Prerequisites: pmwiki-2.2.0
Status: Works
Maintainer:

Questions answered by this recipe

How can I use PmWikis pagelist directive to give me date output? How can I create a calendar where each event has its own page?

Description

This recipe is just a guide to use advanced PmWiki markup to create a simple event calendar. It relies on PageTextVariables and the ftime markup expression to create output for pagelists. It does not include any actual calendar, only a way to track events based on dates.

Basics

The basic approach is to add a date on the page describing your event with a page text variable like this:

(:Timestamp:2009-02-05:)

with a recognizable format. PmWiki should be able to recognize many different formats, but the yyyy-mm-dd is easy to use and has an advantages for pagelist ordering (which is alphabetical). Regardless of how you choose to present it, it is advised that you stick to one format. Different formats may cause some markup to not work as expected.

If you want to display the date differently use the ftime markup to display it. Like this:

{(ftime fmt="%B %d, %Y" when={$:Timestamp})}

Which would give this output: February 05, 2009

Pagelists

To create a pagelist based of upcoming events (with Timestamp set to after today) you need to use ConditionalMarkup. Like this:

(:pagelist if='date ..{=$:Timestamp}' $:Timestamp=-:)

The if part checks the current date against the timestamp, while the PTV-part excludes pages without a timestamp (which would be included otherwise, listing nearly every page on your wiki). A pagelist with previous events is just an inversion of the above (with an exclamation mark), like this:

(:pagelist if='! date ..{=$:Timestamp}' $:Timestamp=-:)

Calendar

To create a calendar first create a Calendar group. In the GroupHeader or GroupFooter of this group put this pagelist:

(:PageList $:Timestamp={$Name}:)

Now the page Calendar/2009-02-05 would display all pages with the timestamp set to this date. By using PmCalendar or another calendar recipe you can have a calendar which links to dates in a calendar group.

Page list templates

To display a date in the pagelist itself, you need to create a PageListTemplates which includes the timestamp variable. This markup shows the date formatted with ftime in a page list template:

{(ftime "%B %d, %Y" {{=$FullName}$:Timestamp})}

Notes

For this to work, it's important to pay attention to the format of the timestamp variable. If it's not uniform troughout the wiki, the markup will not work. For this reason you should also use an unique name for the page text variable. Using Date, Time or any other common words may cause users to unwittingly create page text variables (all you need is the colon) without a recognizable date format. Of course any name would work; Timestamp is used here for convience.

The GuiEditDateButton recipe may help users to always use the correct date format.

Release Notes

See Also

Contributors

Bergwitz

Comments

See discussion at PagelistCalendar-Talk