DTML Calendar Tag API
Tag API
Synopsis:
<dtml-calendar [name="..."] default="calendar" [expr="(expr)" [bgcolor="#rrggbb"] default="#ffffff" [bgcolor_expr="(expr)"] [controls="yes"|"no"] default="yes" [date="(expr)"] [lang="en"|"da"|"de"|"du"|"es"|"fi"|"fr"|"ro"|"it"|"ja"|"no"|"pt"|"zh_TW"|"ru"] [lang_expr="(expr)"] [mode="day"|"week"|"month"] default="month" [modes="day[,week][,month][,year]"] default="day,week,month,year" [images="yes"|"no"] default="yes" [tablewidth="xx%"] [weekdays="[0-7][0-7]"] default="07" > template code </dtml-calendar>
Tag Attributes
name (string)
example:
<dtml-calendar name="calendar1"> <dtml-var date fmt="%d"> </dtml-calendar>
name of the calendar instance. Used for
query string names. Default is Calendar
.
Two instances on the same page may share the same
name, but if so their controls will be locked
in-step, ie. they will always display the same date
and mode.
expr (expr)
The name of the calendar can be set using a python
expression via the expr
attribute, instead of
hard-coding using name
attribute.
example:
<dtml-calendar expr="'calendar1'"> <dtml-var date fmt="%d"> </dtml-calendar>
lang (string)
the language to display in. See synopsis for valid values.
lang_expr (expr)
a python expression to set the language.
This example sets the language of the calendar based on
the variable pref_lang in the request. If it is not set,
then use the English en
calendar:
<dtml-calendar lang_expr="REQUEST.get('pref_lang','en')"> <dtml-var date fmt="%d"> </dtml-calendar>
mode (string)
valid values are "day","week","month".
example:
<dtml-calendar mode="week"> <dtml-var date fmt="%d"> </dtml-calendar>
modes (string)
Restricts the calendar display to certain modes only.
example:
<dtml-calendar modes="day,month"> <dtml-var date fmt="%d"> </dtml-calendar>
date (string expr)
if supplied, evaluates to the date to show by default
example:
<dtml-calendar date="ZopeTime()"> <dtml-var date fmt="%d"> </dtml-calendar>
bgcolor (string)
background color. Defaults to white (#fffff).
example:
<dtml-calendar bgcolor="#cc99cc"> <dtml-var date fmt="%d"> </dtml-calendar>
Foreground-color is always black.
bgcolor_expr (expr)
Set the background color using a python expression instead. See lang_expr example for an idea of how this may work.
tablewidth (string)
Sets the width of the calendar.
example:
<dtml-calendar tablewidth="50%"> <dtml-var date fmt="%d"> </dtml-calendar>
Variables accessible in the template section
date (date)
date to be rendered by the template.
example:
<dtml-calendar> <dtml-var date fmt="%d"> </dtml-calendar>
mode (string day, week, month)
current display mode.
This example shows the date in full if the display
mode is day
mode, otherwise just show
the day part:
<dtml-calendar> <dtml-if "mode=='day'"> <dtml-var date> <dtml-else> <dtml-var date fmt="%d"><br/> </dtml-if> </dtml-calendar>
firstday (bool)
true
if this is the first time the
template is being rendered for this calendar.
false
otherwise.
example:
<dtml-calendar> <dtml-if firstday> <b><dtml-var date fmt="%d"></b> <dtml-else> <i><dtml-var date fmt="%d"></i> </dtml-if> </dtml-calendar>
linkDate(date [, mode]) (callback function)
returns a url for the current page with the current
calendar set to the given date and in the given
mode (mode defaults to day
.
This is for the convenience of the rendering template for things like linking from a given day in the month mode to the day-mode for that day.
example:
<dtml-calendar> <dtml-if "not mode=='day'"> <a href="<dtml-var "linkDate(date,'day')">"> <dtml-var date fmt="%d"> </a> <dtml-else> <a href="<dtml-var "linkDate(date,'month')">"> <dtml-var date> </a> </dtml-if> </dtml-calendar>
getCalendar(name [, defval]) (callback function)
Returns the given rendering property of the calendar.
If no such property is available, defval is returned.
defval
defaults to NULL.
setCalendar(name, val): (callback function)
Sets the given rendering property of the calendar.