Item Types

As described in the introductory article, an item type is a kind of template which can be used for two things:

  • Creating custom content types, with exactly the fields required for a particular kind of content, e.g. a newsletter, a blog post, etc.
  • Creating custom settings for websites, pages, users, etc.

Item types are created and administered from the Item types node under the Settings area in Dynamicweb backend (Figure 1.1).

Figure 1.1 The Item Types node

You can use the area tree to browse for, and open, any of the existing item types on the solution. The existing item types are also listed in the content pane.

The buttons tool bar also allows you to:

  • Create new item types
  • Refresh the item type list
  • View the item type usage

When creating a new item type, you will first be presented with the item type settings interface – this interface is described below.

The item type settings (Figure 2.1) are used primarily to define what kind of item type is being created and other basic properties of the item type.

The item type settings contain the following:

  1. A section for providing a name, a system name, and optionally a description
  2. A section for defining what this item type can be used for:
    • Extending Website- and page properties
    • Creating pages and/or paragraphs
    • Creating items in an ItemList
    • Extending user group and/or users
  3. A section for customization options:
    • Icon lets you select an icon
    • Customized URLs enables custom URLs for paragraph and page items – these are generated from paragraphname and PageMenuTitle respectively, unless the Use in URL field is set in the page properties
    • Category generates a group with that name in the item types tree(or adds the item type to an existing group)
  4. A section for title and inheritance options:
    • Use field for title lets you select an item field to use as the title – no fields can be selected before they are created, of course, so this setting is set after fields have been created
    • Title allows you to specify item field system name to create a title, in the {{Field1SystemName}} {{Field2SystemName}} format
    • Inherit from allows you to select another item type to inherit fields from
Figure 2.1 The basic item type settings

Generally speaking, these options may seem overwhelming to begin with – it’s easy to get lost in the sheer number of settings and options available to you – but when you have some experience with items, you already know from the beginning what you’re trying to accomplish with the item type, and so checking the right boxes becomes trivial.

An item must always contain one or more item fields (Figure 3.1) – these are the input fields which are used when creating content or configuring a website or a page using the item type.

Figure 3.1 Item fields

To add a new field click New field in the toolbar - this opens the field settings (Figure 3.2).

Figure 3.2 Adding a field

The field settings are used to define the type of field and how it should behave:

  • Enter name, a system name, and optionally a description
  • Select a field type – see more about the various field types in the next section
  • Use the Layout section to set a field group and a position within the group
  • Use the Data settings to set a default value for the field. The Do not include in search checkbox is used to exclude this field from and repositories using the default ContentIndexBuilder

Finally, you can use the Validation settings to set up validation for the field:

  • Make the field required
  • Enter or select a JavaScript RegEx validation expression
  • Write an error message to show to users when the validation fails

You can use values from the context as default values in item type fields.

To do so, use these context objects:

    @Request() – get value from System.Web.HttpContext.Current.Request
    @Session() – get value from System.Web.HttpContext.Current.Session
    @Page() – get value from current Page object, if any. (Current page exists if a valid PageID is in the query string).
    @User() – get value from the current User object.
    @Code() – evaluate C# code
    @Paragraph() – get value from current paragraph object, if any. (Current paragraph exists if a valid ParagraphID is in the query string).
    @ProductID() – get value from current product object, if any. (Current product exists if a valid ProductID is in the query string).

For example:

    @Page(MenuText) – Get title of page
    @User(Name) – get name of user
    @User(Email) – get email of user
    @Code(System.DateTime.Now.AddDays(1)) – get tomorrow’s date
    @Code(1+2) – get 3 (possible, but stupid, granted)

An item type consists of a number of fields - and you have a lot of options when it comes to item type fields:

  • Text fields are for rendering various input fields for text
  • Link fields are for linking to folders, files and items 
  • Select box fields are for letting people select users or products, or for creating lists on the fly
  • Number and date fields are for specifying number or dates 
  • List fields are for letting users select values from various types of lists (with static or dynamic options)

Additionally, you have access to all the HTML5 input fields - and a number of cool-but-unique fields (like the color field and the geolocation field) grouped under the other fields label.

Text fields render input fields for text - these are your options:

Field type

Description

Parameters & Comments

Long text

Renders a multi-line input field for text

Use the extra parameters to control the size of the field in rows and columns

Rich text

Renders a text field and a rich text editor.

An extra parameter lets you select a custom editor configuration - if none is set the system checks if one has been set for the user, and finally defaults to the default configuration defined in Settings > Editing > Editor Configurations.

Text

Renders a simple input field for text (255 character limit).

None

Hidden field

“Renders” a hidden field for passing on values not entered by the user

If you make the field required and does not give it a default value or assign a value automatically to it, the user will not be able to save the item. So don't.

Password

Renders a text field where input is rendered as dots (rather than characters)

None

The link fields let you link to various types of content - internal and external pages, items, files and folders. Here are your options:

Field type

Description

Parameters & Comments

Link

Renders a control for selecting an internal page on the solution or a file from the file manager.

The extra parameters let you control what can be selected; pages, paragraphs or files.

 

You can also choose to only return the page or paragraph ID (rather than an URL). This field cannot be edited from frontend.

Link to item

Renders a control for linking to an item-base page or paragraph.

You can access the item fields of the selected item by using the Item.[LinkToItem].Fields loop.

Folder

Renders a file folder selector – the contents of the selected folder can then be rendered in frontend.

You can specify a search pattern in the field settings to only show files matching this pattern, e.g. *.xlsx to match all Excel files, or 2015-* to match files starting with 2015. Cannot be edited from frontend.

File

Renders a file selector

You can set the default folder and the selectable file extensions using the extra parameters in the field settings. You can also allow file upload and select a max number of files for editors to upload.

The select box fields let user select product or users when creating an item - you can then render user or product details in the frontend when the item is published. You can also let users create custom lists on the fly.

The select box field are:

Field type

Description

Parameters & Comments

User

Select users and user groups.

 

Basic user management tags and loops are available, so you can render various details about the selected users in frontend.

None

Product

Select one or more products or product groups. 

 

Basic product tags & loops are available for rendering the selected products/groups in frontend.

 

Select a paragraph with a product catalog which will be used to render the content in frontend. Specify whether products, product groups, or both may be selected using this field.

 

Inactive products can be selected, but will return a blank page in frontend.

 

Attention! This is NOT a replacement for the product catalog app, and you cannot search, sort or filter products selected with this field.

Editable list

Renders an input box for creating custom lists when creating the item.

Content can be added quicker by entering them in a comma-separated format. They will look a little bit wonky until you save the item type.

You have access to the following fields for adding number and date/datetime fields to your item types:

Field type

Description

Parameters & Comments

Decimal

Renders an field for specifying decimal numbers

Number formatting depends on your backend language; a Danish backend will have comma as the decimal mark and point as a thousands separator, whereas a US backend will have point as the decimal marker and comma as the thousands separator.

Integer

Renders a field for specifying integers (non-fractional numbers)

Number formatting depends on your backend language; a Danish backend will have point as a thousands separator, whereas a US backend will have comma as the thousands separator.

Date

Renders a date selector

To get current date preselected enter NOW as the default value in the field settings.

Date and time

Renders a date/time selector

To get current date preselected enter NOW as the default value in the field settings.

Using the list fields, you can add checkbox lists, a dropdown lists, or a radio button lists to your item types:

Field type

Description

Parameters & Comments

Checkbox list

Renders a list of checkboxes

Checkbox lists with a static source have extra parameters for styling the list options in a grid (each option must have an icon set).

'Allow options sorting' makes it possible to sort the checkbox options on the item type. The sort ID of any checked bozes will then be available in fronted, which makes it possible to react to it in templates. This is is primarily useful for website or page settings.

Dropdown list

Renders a dropdown list

None

Radio button list

Renders a radio button list

Radio button lists with a static source have extra parameters for styling the list option in a grid (each option must have an icon).

When creating list fields, click the pencil to edit the field options. From here, you can also choose between three source types for the list options:

  • static source, where you manually provide labels and values for the list options 
  • An SQL source, where you retrieve a list of labels and values from a database using SQL
  • An Item type source, which allows you to generate list options based on instances of that item type

List field types also contain a checkbox for enabling/disabling encoding of list values. It is checked by default for compatibility reasons, but we recommend that you do not encode list values, as this makes it difficult to index and search for or facet on them.

For dropdown lists, you can also disable the nothing selected option in frontend, if you want the first list option to be preselected from the beginning.

HTML5 introduced new input types, and most of these are all available for item types. Please be aware that not all browsers support all the input types – if a browser does not support a field type, it will default to type text.

These are the available HTML5 input field types:

  • color
  • date
  • datetime
  • datetime local
  • email
  • month
  • number
  • password
  • range
  • tel
  • text
  • time
  • url
  • week

Selecting an HTML5 input field comes with extra parameters (Figure 11.1) for controlling the type and styling of the field.

Figure 11.1 Parameters for HTML5 fields

You can:

  • Select the type of control from the dropdown menu
  • Specify a regular expression pattern to check the input element’s value against – works with input types texturltelemail and password
  • Specify a short placeholder, describing the expected value of an input field – e.g. 70252090 for a Danish telephone number. Works with input types texturltelemail and password
  • Specify the size (width in characters) of an input element – use a non-negative integer greater than zero as value
  • Specify a minimum and maximum value of an input element. You can use a floating point number as the expected minimum and maximum values. Works with input types number, range, date, datetime, dagtetime-local, month, time and week.
  • Specify the legal number intervals (step) for an input element. You can insert a positive floating point number to specify the value granularity. Works with input types number, range, date, datetime, dagtetime-local, month, time and week.
  • Activate or deactivate autocomplete on the input field – works with input types texturltelemailpassworddatepickersrange, and color
  • Specify, that the element is a required part of the submission

You can read more about input types and attributes at w3.org.

In addition to the field types described above, you have access to the following field types:

Field type

Description

Parameters & Comments

Item relation list

Renders a control for adding lists of references to other items of a particular type, e.g. ‘Related News’ based on a News-item.

With the extra parameters you specify the item type selectable, sort by and sort order

Geolocation

Renders geo-location coordinates (format: 56.108145, 10.209894) based on values in other fields on the item

First, create address fields (e.g. Street, ZIP, City, etc.) on the item type where you want to use the geolocation field. Then enter a comma-separated list of the fields you want to use to look up the geolocation in the parameter field on the geolocation field - e.g. street,zip,city. The values entered in the address fields will then be used to look up and render a geolocation.

You can override the retrieved coordinates with your own by checking the override retrieved coordinates checkbox.

Color

Renders a color selector which lets you select a color, enter a color code or select a preset color

Preset colors are defined in item field settings using the ‘Presets’ field.

Checkbox

Renders a check box

None

Item type

Renders fields from another item type within this item type.

This field type lets you create little content blocks and reuse them again and again when building item types.

Item tab Select another item type - the fields from this item type are rendered in a tab below the regular website properties Allows you to group & organize your website properties - used extensively on Rapido.
Google font Allows you to select a Google Font family and font weight You must provide a Google Fonts API key under Settings > Control panel > Item settings to use this - read more here

 

Item fields may be organized in groups (Figure 13.1) – this is useful for two reasons:

  • It’s easier to see what’s going on when fields are groups
  • You can set conditions on when to show a particular field group
Figure 13.1 Field Groups

To create a field group click New group in the item type toolbar and fill in the field group settings (Figure 13.2).

Figure 13.2 Field group settings

When you’ve created a field group, remember to move (drag & drop) or create a new field under it – if you save an empty field group, it is removed by the system.

By default, new item types are unavailable – they can’t be used anywhere. To enable an item type you must open and configure the item type restrictions, which specify precisely where the item type can be used.

  • Click Restrictions in the toolbar to open the restrictions interface (Figure 14.1).
Figure 14.1 The item type restrictions determine where an item type can be used

The restrictions interface allows you to specify exactly where the item should be available; allowed websites, parents & children.

From both the item type list and the individual item types you can click the Item type usage button to access an overview of where item types are used (Figure 15.1).

Figure 15.1 Item type usage overview

You can filter on item type, website, and also the kind of item (used in).

Please note, that this list will not inform you if an item types is used in another item type, whether through inheritance or through the Item. Always back up your item types before deleting an item type.

Database

There is no database specific information for this subject.