Xataface 1.0 includes a built-in calendar action that is disabled by default. If enabled, it allows you to view the records in any found set as a calendar of events, as follows:
Hourly schedule for any day by clicking on it.
Show record details instantly by clicking on it in the calendar.
Recognizes dates, start and end times for records when interpreted as calendar events.
Respects searches (i.e. you can filter the records and the calendar will only show those records in the found set).
Your table records should contain at least dates in order for them to be interpreted as events that can be placed in a calendar.
Setting up the Calendar
Suppose I have a table called Lessons that stores information about scheduled music lessons. If I want to add the calendar to this table, then I would add an actions.ini file to the tables/Lessons directory with the following contents:
[calendar > calendar]
This overrides the calendar action which is disabled by default, and enables it for the Lessons table.
Next I need to inform Xataface which fields store the event dates and times so that the records can be laid out in the calendar appropriately. (Note that if you skip this step, Xataface will make a best guess based on column types and names - but it is better to specify these explicitly).
In the Lessons table I have the following fields that are relevant here:
lesson_date - A date field containing the date and start time of the event.
start_time - A time field with the start time of the lesson.
We can tell Xataface to treat these fields accordingly by adding the following directives to the appropriate field sections of the fields.ini file for the Lessons table:
event.date=1 - Specifies that the field stores the date of the event.
event.start=1 - Specifies that the field stores the start time of the event.
Now if we load up our application, we should now see a calendar tab along side list, details, and find for the Lessons table. Click on this tab to see your records displayed in a calendar.
Using a datetime field to store both date and start time
You can also use a single field to store both the date and start time for an event. In this case you just provide the event.date and event.start directives for the same field. For example if the lesson_date was a datetime field that marked the date and time of the lesson, we would modify our fields.ini? file as follows:
The Calendar action will look for the following pieces of information in your records:
Indicates that the field contains the date of the event.
Indicates that the field contains the start time of the event.
Indicates that the field contains the end time of the event.
Indicates that the field contains the location of the event.
Indicates that the field contains the category of the event.