Saturday Sitecore Learning - Templates Part 2 (Simple Field Types)

Template Fields

This is the second post as part of Sitecore Template series.

Sitecore 8.2 (rev. 160729)

In this post, let’s discuss about fields, and their types. If we think of a template as a class, then fields are properties of that class. We can consider each field is container for the individual piece of content (image, link, text, list, etc.), and using this fields Content Authors can add/update their content.

How each property of the class has its own type, similar way each template field also has its own field type. Field type determines, three things

  1. What type of content (normal text, rich text, image etc.) can be entered into the field,
  2. What type of control (Single line text, Rich text editor, etc.) need to be shown to content authors to enter their data,
  3. In what format the value is stored in the database.

Out of the box Sitecore provides lot of field types, but based on the requirement, developers can create custom field types. From requirements, or from design, developer has to infer the fields & corresponding field types required for particular page, or module.

We can classify/categorize field types as shown below,

  • Simple types
  • List types
  • Link types

Let’s look into each type in detail,

Simple types:

The Simple type field contains individual values, like a text, integer, or date value.

  • Single-Line Text: This is one of the most commonly used field type, and also the simplest one. It is similar to a HTML textbox control, and allows content authors to enter simple text.
    Raw value: string
    Field type class: Sitecore.Data.Fields.TextField
    Field Renderer supported: Yes

  • Multi-Line Text: As the name suggests this type is used when we have multiple lines of text/comments to be added. This is similar to HTML textarea control.
    Raw value: string
    Field type class: Sitecore.Data.Fields.TextField
    Field Renderer supported: Yes

  • Rich Text: This field type allows content authors to enter large text with media items, and also allows to modify HTML. This is similar to WYSIWYG editor.
    Raw value: XHTML
    Field type class: Sitecore.Data.Fields.TextField
    Field Renderer supported: Yes

  • Integer: This field type allows content authors to enter whole number. It’s also similar to HTML textbox control.
    Raw value: string
    Field type class: Sitecore.Data.Fields.TextField
    Field Renderer supported: Yes

  • Number: This field type allows content authors to enter decimal values. It’s also similar to HTML textbox control.
    Raw value: string
    Field type class: Sitecore.Data.Fields.TextField
    Field Renderer supported: Yes

  • Password: This field type is used for passwords, where characters in the field are masked. It is similar to HTML input control with password type.
    Raw value: string
    Field type class: Sitecore.Data.Fields.TextField

  • Date & Date Time: As the name suggests both of these field types are used for date & date time respectively. This field types allow content authors to select or manually enter the data and time. These are similar to HTML input control with date type.
    Raw value: string (ISO 8601 formatted date-time, yyyyMMddThhmmss)
    Field type class: Sitecore.Data.Fields.DateField
    Field Renderer supported: Yes

  • Checkbox: This field type allows content authors to check/uncheck a particular value, and it’s similar to HTML input control with checkbox type. It contains either 0 or 1 value.
    Raw value: 0 or 1
    Field type class: Sitecore.Data.Fields.CheckboxField
    Field Renderer supported: No

  • Image: This field type allows content authors to select an image from the media library and specify image properties.
    Raw value: xml
    Field type class: Sitecore.Data.Fields.ImageField
    Field Renderer supported: Yes

  • File: This field type allows the user to select an item in the media library. Users can click Open file to open the Media Browser and select the desired file from the media library.
    We can use the Source property of a File field to control the media folder selected when the content author opens the Media Browser, or to specify the root item for this selection interface.
    Raw value: xml
    Field type class: Sitecore.Data.Fields.FileField
    Field Renderer supported: No

  • Word Document: The Word Document field type allows the content authors to edit HTML using Microsoft Word embedded in the browser. (I have not yet used this field, and it is only supported in IE browser)
    Raw value: xml
    Field type class: Sitecore.Data.Fields.WordDocumentField

Raw value: A value which gets stored in the database for each field.
Field type class: Using which developer can access the field values.
Field Renderer supported: Field type has corresponding FieldRenderer web control, when used, content authors can use Experience editor to manage the content for particular field.

In coming posts, will look into List and Link types.

References:

Happy Learning :)

Share