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 the icon used when creating an item and in the page tree/paragraph list. 
    • Image lets you select an image used when creating an item and in the page tree/paragraph list
    • 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.

See this article for more information on the different item field types.

Item fields may be organized in groups (Figure 6.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 6.1 Field Groups

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

Figure 6.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 7.1).
Figure 7.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 8.1).

Figure 8.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.