Content types are composed of elements, which are individual fields that you can define and configure in detail. For example, a press release can contain a title, date and body text. Each of these elements can be styled separately. These elements are specified in the Elements field on the Add Content Type screen.
To specify an element, use the following syntax:
[element_name
] type = "element-type
" options.label = "screen-label
" options.description = "description
"option name
= "value
" ...
The element_name
, type
and
label
are required.
Additional options enable you to specify attributes of the element such as whether it is required, how it is filtered, formatted, validated, and so on.
For example, the following code specifies the elements for a Press Release:
[headline] type = text options.label = Headline options.required = true display.tagName = h1 display.filters.0 = HtmlSpecialChars [icon] type = imageFile options.label = Icon options.required = true search.index.disabled = true [date] type = dateTextBox options.label = Release Date display.filters.0 = HtmlSpecialChars [description] type = editor options.label = Description display.filters.0 = DefaultStripTags
Zend Form Elements | |
---|---|
Perforce Chronicle content type elements are based upon Zend Form Elements and Zend Dojo Form Elements. |
You can use the following element types to define content types:
Table 4.1. Element Types
Type | Description, Example, Options |
---|---|
checkbox |
Displays a single check box. To display a label for the check box, set
the options.label parameter. To specify the values
returned when the user clicks , specify the
options.checkedValue and
options.uncheckedValue parameters. To configure the
default state of the check box when first displayed, set
options.checked to true (checked) or false (unchecked).
|
dateTextBox |
Displays a field in which users enter dates. Also displays a calendar
date-picker. To configure the format in which dates must be entered,
specify the datePattern parameter with a
Unicode
date format. To configure whether white space variation is
tolerated, set the strict parameter to true or false.
|
editor |
Creates a WYSIWYG editor box. You can add plugins to
the editor by specifying
Dojo
editor plugins for the desired options, as shown in the example
code. You can also create custom editor plugins in Javascript and add
them. It is important to specify the DefaultStripTags display filter as
shown in example to remove any malicious HTML.
[Recipe] type = "editor" options.label = "Enter your recipe" options.extraPlugins[] = "fontName" options.extraPlugins[] = "fontSize" options.extraPlugins[] = "formatBlock" options.extraPlugins[] = "toolbarlinebreak" options.extraPlugins[] = "foreColor" options.extraPlugins[] = "hiliteColor" options.extraPlugins[] = "||" options.extraPlugins[] = "insertImage" options.extraPlugins[] = "createLink" options.extraPlugins[] = "pagebreak" options.extraPlugins[] = "viewsource" display.filters.0 = "DefaultStripTags" |
file |
Creates a form element that enables users to upload files.
[File] type = "file" options.label = "Press Release" options.description = "PDF format (30K - 1M)." options.validators.mimeType.validator = "mimeType" options.validators.mimeType.options = "application/pdf" options.validators.size.validator = "Size" options.validators.size.options.min = 30720 options.validators.size.options.max = 1048576 |
imageFile | Creates a form element that enables users to upload images. |
imageSelect | Creates a form element that enables the display of multiple images as a group, and enables adding images via drag-and-drop for supported web browsers. |
multiCheckbox | Displays a list of checkboxes. |
multiselect | Displays a list of options. |
radio | Display one or more radio buttons. |
select | Creates a drop-down list from which users choose an option (a pick list). [please note, the key's value is shown when the content is displayed, not the label.] |
text | Displays a single line plain text entry field. It is important to filter the output as shown in the example to ensure entered data is interpreted as plain text. |
textarea | Displays a multi-line plain text field. It is important to filter the output as shown in the example to ensure entered data is interpreted as plain text. |
validationTextBox |
Displays an entry field and specify the format in which text must be
entered into it. It is important to filter the output as shown in the
example to ensure entered data is interpreted as plain text.
[TwoWords] type = "validationTextBox" options.label = "Two Words" options.required = "1" options.regExp = "[\w]+[\s]+[\w]+" options.invalidMessage = "Input must two words separated by whitespace." options.validators.regex.validator = "regex" options.validators.regex.options.pattern = "/^[\w]+[\s]+[\w]+$/" display.filters.0 = "HtmlSpecialChars" |
You can specify a default value for an element:
options.value = "The default value for this element"
Chronicle uses functionality provided by the Zend framework to enable you to
validate and filter user input. It is important to appropriately filter displayed values
for fields which allow text entry. You can allow a subset of HTML
tags/attributes to be used via the DefaultStripTags
filter;
this is recommended for the editor field type. Further, you can ensure the value is
interpreted as plain text via the HtmlSpecialChars
filter; this
is recommended for any fields accepting arbitrary user input such as text and textarea.
[title] type = "text" options.label = "Title" display.filters.0 = "HtmlSpecialChars" [body] type = "editor" options.label = "Body" display.filters.0 = "DefaultStripTags"
[title] type = "text" options.label = "Title" options.required = true display.tagName = "h1"
[hideme] type = "text" options.label = "Not Normally Visible" display.render = false
[author] type = "text" options.label = "Author" display.showLabel = true
Using Macros in content is possible when an element's definition includes:
options.macros.enabled = true