What is Template Based Display

Template Based Display is a very powerful feature that allows you unlimited control over the look and feel of your calendar web pages. This is accomplished by providing you three custom HTML tags as described below.

The basic idea is that you create a normal HTML page, containing any HTML code you like such as your menus, page footers, page headers, etc. Into this page you insert custom tags (called <cw_tags in the following). Theses custom tags allow you to include various parts of the calendar in the web page (such as the month grid, calendar menus and program icons for example).

Place the file contain these tags in the calendar's data folder and call it template.htm (so the program can find it). From that point on, every time the program runs, it will read the template.htm file and replace any <cw_tags with the HTML code needed to display that object (such as the calendar body for example).

Like HTML tags each of the three custom tags has various attributes (name=value pairs) that indicate the options for that tag. For example, the <cw_d> tag has an attribute called 'cmd' which can take on values such as 'calendar', 'todo', or 'contact'. When this tag is processed the HTML code for the calendar, to do list or contact list will be inserted into the web page and the page will be presented to the end user.

Details about each of the three tags are presented in the following help pages:

An example

The simplest possible template.htm file is this:

      filename: ./data/calweb/template.htm
<html> <body> <!-- regular HTML code --> <h1>Hello World</h1> <!-- custom tag --> <cw_d object=body> </body> </html>

This will cause the calendar display to appear thus:

How is the Template File Selected

After creating the template.htm file you have a couple of options on how to use it:

  1. Create an file in the data file called template.htm containing any HTML code you like. Make sure to include one or more of the <cw_ tags described above.

    Run the program.

    If the program finds a file called template.htm it will read it, parsing through it looking for <cw_tags. Wherever such a tag is encountered the program replaces the tag with the HTML code needed to render that object. All other text it finds is passed through untouched.

    The template.htm file is placed in the root of the data folder and effects every calendar that is served from this server. See the below to customize individual calendars.

  2. To customize a single particular calendar move the template.htm file into the calendar's data folder instead of into the top level of the data folder (./data/calweb). You may place a different template.htm file in each calendar - allowing you to customize every calendar completely.

    The algorithm for finding templates is:

          if (template.htm exists in calendar folder)
              use it
          else if (template.htm exist in ./data/calweb)
              use it
          else
              render the calendar with no templates
    				

  3. Finally, you may specify the template directly on the URL. To do this attach the text:

          &tmpl=your_template_name.htm

    to the end of the program's URL.

      Note: Make sure that if this item is the first item after the script name you use "?tmpl=" instead of "&tmpl=".

Samples

There are a number of sample display templates that come with this program. Please look in a folder called ./data/samples.. This folder contains a readme.htm file which will explain how to use the samples. Please see that file for more information.

The example of most interest is the file called alltags.htm. This sample shows you an example of every available tag.

  • Case Insensitive:

      As is true of HTML in general, the tags and options available for the <cw_ tags are case-in-sensitive. This allows you to code to the style of your choice.

  • The Body Tag:

      Normally the program passes through untouched any text in the file that does not start with <cw_. The HTML <body> tag is a special case. This is the only HTML tag that we process.

      For the <body> tag we preserve all your optional settings, however if any of the following attributes is not already present we add it. We add these missing items with values picked up from the calweb.ini (the calendar configuration file) found in the calendar folder.

      The items that are added (if and only if they are not already present) are:

        bgcolor
        text
        link
        vlink
        alink
        background
        onload (for adding our Javascript code)

      This is necessary to make our program function properly.