Event calendar

Overview

A simple event calendar for Website Baker CMS -based websites.
Two modes:
  1. normal calendar page, can be customized through template if desired
  2. small menu calendar showing current month

Installation

Module installation is done like described for ban module.

In order to have small menu calendar, you must edit the index.php -file of the style template used.
Add the following lines into the index.php file of style to the location where you want the small calendar to appear:

<?php
require_once( WB_PATH.'/modules/event_calendar/calendar.class.php' );
$cal = new Calendar( $database, 'menu' );
echo "".$cal->writeCalendar();
?>

You can also make a code section on the page you would like the small menu calendar appear.
In the code section add code like this:

function small_cal {
global $database;
require_once( WB_PATH.'/modules/event_calendar/calendar.class.php' );
$cal = new Calendar( $database, 'menu' );
echo "".$cal->writeCalendar();
}

[Thank's to marathoner for the code section tip, please take a look on his pages
using this calendar at http://www.secondsoletotalsports.com ]

Installation adds one table to the database ('{TP}MOD_EVENT_CALENDAR') and makes few inserts into the {TP}SEARCH -table of your Website Baker database. See below for more info.

Uninstallation

Before uninstallation remove all pages that are based on the Event Calendar module.

Module uninstallation is done like described for ban module.

Uninstall script also drops the database table used by event calendar, and removes the additions made to {TP}SEARCH -table.

To remove the small menu calendar, remove above mentioned rows from the index.php -file of the style template used.

Usage

Event calendar has one public page that can be set viewable.
After installation there is a new page type available in the Add Page -dialog: Event Calendar.
Add a new page of type Event Calendar like you would add any other type of page in order to have an event calendar page. [Note: if building a multilanguage website, after adding the new page make sure you go to Change Settings -page of the newly added page and set the language there as well.]

Added event calendar (used without template) page looks like this (if the CSS file from the distribution is used):

Elements of the calendar page:
By using template you can customize the calendar window to your liking. For example you can have small calendars for previous and next months (navigation is done by clicking the small month):



Event details can be shown under calendar in three different ways depending on the configuration:

Mode 1: event details are shown only after clicking the event in the table.


Mode 2: Event details are shown automatically when there are events. Clicking the event in the table has no effect.



Mode 3: Event details are shown in a popup window. You can modify the popup window easily since it's structure is read fom template.

Small menu calendar looks like this:


No event info is shown on the menu calendar. Different color can be set for current day and day for which there is an event (in the example above current day is shown red and days with events green).

Events can be added only by administrator or users with admin rights for the event calendar. Therefore, log in, go to the admin pages of your Website Baker installation and click on the calendar page you've added to your website. The following page is shown:



This is the calendar administration page. To add an event, click on Add new event.
The following page is shown:



A page with event detail fields are shown.
If start time or end time of event is not given, default values will be used.
These default values can be set in settings ($SMTEXT['admin']['default_starttime'] and $SMTEXT['admin']['default_endtime']).

After filling out the data, click on the Save -button.

Event is written to database and shown in the Events list.

You can preview the event by clicking on the magnifying glass next to the event or the event caption:




To edit the event, click on the Edit icon shown in the same line as event caption or click on Edit event while previewing the event. Event details are shown in editable fields.

To delete the event, click on the Trash icon in the same line as event caption or click on Delete selected while previewing the event.

Remove past events: clicking this deletes the events that have passed (i.e. events who's start date and time has gone).

Note on the event adding in multilanguage environment:
With event data also the currently active language is saved. This means, that you must use the language you want the event be shown also while adding evens in admin side of your Website Baker installation.
So if you have a multilanguage website with, for example finnish and english pages, events you add while using english language in admin pages are shown only in the calendar that is used on the english pages of your web site.

Note on the search functionality of Website Baker:
One can not (currently) limit the search function to show only events for current language (seems to be the problen also for other modules, too). So if you have a multilanguage website with, for example finnish and english pages, using the search on english side will return also the finnish events if the search is able to find a match in the finnish text.
Currently the only way to prevent this is to disable the search intergation between event calendar and Website Baker. This is done by running the following SQL's against the database used:
  1. DELETE FROM {TP}search WHERE name = 'module' AND value = 'event_calendar';
  2. DELETE FROM {TP}search WHERE extra = 'event_calendar';
Make sure to substiture the {TP} in the above SQL commands with the table prefix used by your Website Baker installation before running these!

Also there seems to be bug in the search results page of Website Baker: it doesn't show the menu correctly after search (try the search on this web site to see the effect: only 'en' is shown on the menu after search).

CSS file configuration

Event calendar style can be configured thru CSS file.
The name of the CSS file used can be set in language file. Thus one can have different look for calendar on different languages if desired.

The following CSS -classes are used by the event calendar:
For menu calendar the same class names are used but with menu prefix (i.e. 'menucalendar_monthyear', 'menucalendar_daynames', 'menucalendar_main' etc.)

Language file configuration

Language files are used not only for setting text string in different languages but to set few configuration settings for the calendar. This is usefull if you have a multilanguage web site: you can set for example the date and time formats to be different on different pages of your web site. For example one can use the system settings (set in Settings page of Website Baker) while using language1 pages, and other date and time format settings while using language2 pages. The format used is standard PHP date -function format (see www.php.net/date).

Apart from the text strings the following setting are set in language file:
Note on the date_format -setting:
If you want to use the system settings set in Settings page of your Website Baker installation, use this:
$SMTEXT['date_format'] = DATE_FORMAT." \a\t ".TIME_FORMAT;

You can set the text between date and time formats using escapes (the '\a\t' in above).

Template file configuration

Event calendar can use two template files: calendar_view_XX.html and event_details_XX.html (XX should be substitued with your landuage prefix).

Template files might have some text strings that have to be translated. By default an english language template files are used but if you want to have these templates in your own language, copy the english file to your own language file (change the language prefix in the file name) and translate the file contents to suit your needs.

Template files are normal HTML files, therefore you can edit the contents of these files if you are familiar with HTML coding to equal your web site style etc. However, these template files also have markers where data is shown on these pages, these markers are written like {MARKER_NAME}. If you edit the templates make sure you do not edit these markers. However, you can delete them completely in order to hide data from the page.

Use of the template files is set in the language file:

calendar_view_XX.html
With this file you can control the main calendar view.
For example you can have small calendars on top of the page to display previous and next months, these act also as links when browsing months. The template is basically just a HTML table which is used to position different parts of the calendar window. You can edit this structure if needed.

The following data markers can be used:

event_details_XX.html
This template defines the layout of the popup window to display event details.
There is a style section in the beginning of the file where you can set the style used in this popup window.

The following data markers can be used:

Database changes

Event calendar uses only one database table: {TP}MOD_EVENT_CALENDAR (where {TP} is the table prefix used by your Website Baker installation).

The table has following fields:
Primary key of the table is the id -field.

Installation of the module makes also additions to the {TP}SEARCH -table of your Website Baker installation.
Please see note about the search integration above. If you wish not to include calendar in the search, use the SQL commands shown above to remove the additions made to {TP}SEARCH -table.

Feedback

All feedback is welcome!

If you find this module usefull, please drop me a line.
If you find a bug, please let me know so that it can be corrected.

Download

You can download the module here.

Version history

Version 1.1.1, 10.8.2006
- minor bug fixes
- added required field checks in admin when adding events

Version 1.1.0
, 9.8.2006
- Template page can be used to display calendar. One can edit this template to suit his/hers nedds for calendar display (you can have small calendars for previous/next month etc.).
- Event details can be shown on popup window if desired.
- Multiday events are shown correctly in the calendar.
- Today -link text above calendar can be now customized.
- Current month and browse links can now be hidden if desired.
- Event start and end times can now be shown in the calendar cell.
- More than one events are shown correctly in calendar cells.
- Day can now be entered by picking it up from small calendar in admin.
Pickup calendar used: http://www.garrett.nildram.co.uk/calendar/scw.htm
Time can be entered by picking it up from a select list.
- Added check: start date < end date.
- Events are now sorted after the start time in events list in admin page.

Version 1.0.0, 4.8.2006
- Initial release.

Powered by Website Baker