Item Types
An item type is a sort of mold, from which you create new items.
Being able to create new item types therefore gives you access to a generic and powerful way of creating, managing and presenting content or data on a website.
You could, for instance, create item types tailor made for creating:
- Blog posts
- Newsletters
- Contact forms
- Employee profiles
- Course descriptions (and signup)
- Calendar events
- Extending your website or page properties
- Etc.
An item type contains of a number of item fields, which define what the item does (or contains) when created - for a blog post item, you probably want a rich text editor field, for instance - and a number of settings controlling item behavior.
Basic Concepts
In this section, you will learn:
- How to create (and delete) an item type
- How to create an item field
- How to create and use field groups
- How to use item type restrictions
- How to get an overview of item type usage
Getting started with item types
To get started with Item Types:
- Go to your Management center
- Click Item types in your management center tree
- You will now see the Item Types overview (Figure 3.1)
From here, you create and manage your item types.
Creating an item type
To create an item type:
- Click New item type on your item types overview.
This brings up the Settings window for the new item type.
Here's a rundown of the settings.
Basic item type settings
The basic item type settings (Figure 5.1) are common to all item types.
You can:
- Name the item type – this is obligatory
- Customize the system name of the item type. A system name is auto-generated from the name, but can be changed. The system name does not allow spaces or special characters – these will be replaced by an underscore when the item type is saved. The system name is stored in the database, and in an XML file placed in Files/Systems/Items
- Provide a description of the item type. Do this to avoid problems down the line – you want people to know what an item is for, and what it does.
The "Enable Item type for"-settings
In order to use an item type, you must first enable it for your intended use.
You can:
- Enable the item type for website and page properties
- Use this for items types, which are used to extend the standard website- or page properties settings. Read more about extending website or page properties.
- Enable the item type for pages
- Use this for item types, which create new pages (e.g. Newsletter items)
- You must specify the default view when creating a new item. You can choose between the item view (showing item content fields) and the paragraph list view. Read more about working with item based pages.
- Enable the item type for paragraphs
- Use this for item types, which create new paragraphs (e.g. blog posts).
- If you want to allow module attachment on the created items, check the appropriate box.
- Read more about working with item based paragraphs.
- Enable the item type for ItemLists
- Use this for item types, which handle or create data that should not be immediately accessible from your site (e.g. form data). Read more about working with item lists here.
To enable an item for one or more of the four areas, simply check the appropriate checkbox.
The item type icon/thumbnail settings
You have the option of using a custom icon and thumbnail for your item type.
The selected icon and thumbnail will be used for the item in the page/paragraph trees, the page/paragraph template lists, and in the item type lists.
You can use one of our icons, or upload one of your own, as long as it uses a 16x16px format.
Other item type settings
A number of other item type settings may be relevant to you.
You can:
- Generate customized URLs when using the Item Publisher to publish items of his type. If the item is a paragraph, the URL name is generated from paragraphname. If the item is a page item, the name is generated from the pagename (PageMenuTitle), UNLESS the Use in URL field is set on the page properties, in which case the value of that field is used.
- Enable Item cache, in which case all cacheable item types will be served from cache, until an item is invalidated (is edited, or the application pool is recycled)
- You can categorize items, e.g. if you create several different kinds of blog post items. To categorize an item, enter a path in the category field, e.g. MyCategory/MySubcategory/. If the category does not exist, it will be created when the item type is saved. Categories are store in the item type xml. A category which contains no item types is automatically deleted.
- You can customize how items based on the item type are titles. You can use a field for the title, or you can specify a pattern of field system names to use in the Title setting. For instance, using {{Field1SystemName}} {{Field2SystemName}} creates a title based in the content from Field1 and Field2. Leave blank to make page/paragraph name editable.
- You can select an item type to inherit fields from. Note that field settings are not inherited.
Once you are happy with your settings, click OK.
Don’t forget to save your settings before leaving the item type page.
Creating an item field
To create an item field:
- Go to your item type
- On the toolbar, click New field (Figure 9.1)
This brings up the field settings window.
Field settings
When you create a new field, it must be configured, using the settings window (Figure 10.1). Most settings are general, and common to all field types – here’s what they mean.
With the general settings, you:
- Provide a name for the item field
- Provide a custom system name for the field - or leave the one generated from the name. Remember, the system name doesn’t allow special characters or spaces. You will use the system name with template tags, when rendering the front end.
- Provide a field description, which will be placed below the field in dimmed grey on the frontend.
- Select a field type – e.g. Rich Text (for a rich text editor) or Password (for a password field). For a complete list of field and descriptions, read the following sections.
You also have access to field layout settings (Figure 10.2).
With the layout settings, you:
- Can select a group for the field – read more about field groups.
- Select the position of the field in the group
You also have access to the field data settings (Figure 10.3).
The data setting – default value – enables you to enter a default value for the field.
The default values allowed are of course dependent on the field type – check boxes accept true/false, text fields accept text, integer fields accept integers, and so forth.
Please note, that currently file fields do not accept a default value starting with a / - so use 'images/favicon.png' and not '/images/favicon.png'.
You can also use context sensitive default values – read more about that here.
You also have access to the field validation settings (Figure 11.1).
With the validation settings, you can:
- Set a field to be required – the user won’t be able to save the page or paragraph if a required field has not been filled.
- Set up validation rules, to ensure that the values entered in the field conform to whatever standard you want to set up. You can enter a custom validation expression based on javascript RegEx, or select one from a list of standard expressions by clicking the scroll icon. Validation is only available for the field types Text, Long text, Hidden and Password.
- Write an error message, if you want to inform the user that they have entered something which didn’t conform to the validation rule above.
In addition to these general settings, some field types have custom settings – these will be described in full under the field type descriptions below.
Field types
In the following, you will be able to see a description of the various field types available to you, as well as any custom parameters associated with the field type.
Check box field
A check box field creates a check box (Figure 13.1) – no more, no less.
Color field
With a color field (Figure 14.1), the user can select a color, write a color code, or select a preset color, if defined in the item field definitions.
The color field has an extra parameter in the item field settings, when you create or edit a field. With that parameter (Figure 14.2), you can write a list of preset colors.
Each of the colors in the preset field will be rendered as a little box after the color selection box, and are available for selection by the user.
Date & Date and Time field
With the Date and Date and Time fields, it’s possible to select a dare in a calendar selector.
To get the current date when creating a new item with the item type, enter NOW as the default value in the field settings
Decimal number & Integer number field
With the decimal and integer fields, you limit the user to entering numbers (decimal numbers and integers, obviously).
Number formatting depends on your backend – if you are logged in with Danish backend, the decimal mark is a comma, and the thousands separator is a point, and if you are logged in with the US backend, the decimal mark is a point, and the thousands separator is a comma.
File field
A file field (Figure 17.1) allows the user to select a file from the file manager.
The file field has extra parameters (Figure 17.2) in the item field settings, when you create or edit a field.
With these parameters, you can:
- Select which folder should be opened by default, when the user opens the file browser
- Limit the user to certain file extensions, e.g. gif, jpeg, etc. Comma-separate extensions if you allow more than one type of file.
From 8.7.0.0, you can also allow file upload from the frontend, and select a maximum number of file uploads to allow. If you are working with templates created before 8.7, you must change them to render the upload functionality. Check the default 8.7 templates to see how.
It is possible to use the file for uploading files too, but it requires a little bit of fidgeting.
To do so, insert an input field in your edit template, e.g.:
<input type="File" name="FileTester" accept="<!--@ItemPublisher:Edit.Item.FileTester.Extensions-->" style="width:250px;">
Where ‘File’ is the item field system name.
Folder field
With the folder field (Figure 18.1), you select a folder in the file manager. In frontend, you are then able to create and display a list of the files in that folder, by using a template loop.
The folder field has an extra parameter (Figure 18.2) in the item field settings, when created or edited. With this parameter, you can specify a file search patter, to limit the list of files to be rendered – only rendering e.g. images, excel spreadsheets starting with “2015-“, and so forth. Use wildcards such as * and ? to create a search pattern matching the files you want to loop through.
When editing an item field of the type Folder from frontend with Item publisher and Item creator, the field is rendered as text field and it is not possible to select a folder.
Geolocation
This field renders a geolocation in the 56.108145, 10.209894 format, when a valid address is entered in the address fields you have defined in the extra parameters.
If, for instance, you have the fields street, number, ZIP, and city defined, the system performs a geolocation lookup based on the content of those fields (Figure 19.1):
The address fields are created by writing the labels in the extra parameter field in the field settings - above, the values were Street,Number,ZIP,City.
You can override the retrieved coordinates, and insert your own, by checking the appropriate box – in which case you may want to use the field without parameters at all.
Hidden field
A hidden field is similar to a text field, but is not visible. Since it is hidden, the purpose should be clear – to submit information, which has not been entered by the user.
If you mark the field as required, and don’t provide a default value, the user will not be able to save the content. This is generally not what you’re looking to do.
Input (HTML5) field
This field makes it possible to render an HTML5 input control. Note, that not all browsers support all the new input types. If not supported, the field will behave as a regular text field.
The input (HTML5) field has several extra parameters in the item field settings, when created or edited. With these parameters, you can render an HTML input control.
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 text, url, tel, email 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 text, url, tel, email 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 text, url, tel, email, password, datepickers, range, 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.
Item list field
The item list field (Figure 22.1) allows you to dynamically generate a list of items of another item type, from within an item type.
Using this field gives you an ItemList field, where you can add items of the chosen type (e.g. newsletter paragraph items) to the item you’re creating (e.g. a newsletter page item).
The columns which show up in the list of added items are specified in the extra parameters (Figure 22.2) available for the Item list field, when it is created or edited.
With these parameters, you:
- Select the item type which should be available for the field. Once an item type has been selected, click Edit file options to select which fields to show in the Item list, after creating the new item.
- Select what field you want to sort the list by, and select a sort order for the list.
You cannot list items, which contain item list fields themselves. Likewise, you cannot save an item type which contains item list fields, if it is set to be available for item lists. This is to prevent the Borg from assimilating us all.
You cannot delete an item type, which is used in an item list within another item type. You need to deselect the item type from the item list field parameters to be able to delete it.
Frontend editing of an item list, using the item publisher and item creator modules, is not possible, and the item list will not be rendered.
Item relation list field
The item relation list field allows you to add a list of references to other items of a specific type, e.g. related news. Read more in how to set up an item relation list here.
The Item relation list gives you access to a field, where you can add related items of an item type, when creating a new item.
The item relations list field has a number of extra parameters (Figure 24.2) available when created or edited.
With these parameters, you:
- Select the item type you want to be able to select, when adding an item relation (for instance, you could limit the type to an item type called ‘News’, in which case you can select only other News-items to list as related content when creating a new News item). The edit field options icon, next to the item type selector, allows you to customize which fields you want to list in the item relation list.
- Specify a column to sort by, and a sort order for your item relations list
- Select an item source (pages only, pages & paragraphs, or paragraphs only)
- Specify a minimum and maximum number of items which must be related to the item, when it is created.
You cannot delete the item relation list type, if it is used as a reference somewhere. You must remove all references to be able to delete the item type.
Frontend editing of an item relation list, using the item publisher and item creator modules, is not possible, and the item relation list will not be rendered.
Item type field
The item type field can be used to include/share fields from another item type within an item.
For example, if you have an Address item type with Street, Zip and City as fields and another item type called Phone with Phone and Mobile phone as fields.
You then have an item type called Person, where you have a Name, Birthday, Title and an Employed field. Here you can add two item type fields, selecting the Address item type and the Phone item type.
Now, whenever you create a new Person item, the item will contain the fields from the Address and Phone item types.
In this way, you can create little item-blocks and use them again and again, when building content.
Link field
With the link field (Figure 27.1), it’s possible to select an internal page or a file from the file manager.
The Link field has extra parameters (Figure 27.2), when created or edited.
With these parameters, you can:
- Enable (or disable) linking to a page, paragraph or file when using the link button
- Choose to select and render only the page or paragraph ID. If this box is not checked, and you select a paragraph, it returns an URL, e.g. Default.aspx?ID=2556#2743, but if the box is checked, only the ID (2743) is returned.
If Select only page or paragraph ID is checked, and you select a paragraph, you will get redtext, because the system believes it to be a page ID, rather than a paragraph ID, and no page with that ID exists. Don’t worry, you did nothing wrong, and everything works as it should regardless.
Frontend editing of a Link field using the Item publisher and Item creator is not possible, and the field will be rendered as a text field. If the system recognizes the text as an external link, it adds http:// in front of the link
Link to item field
With the link to item field (Figure 29.1), you can link to an item based page or paragraph, and get a list of the item fields for the selected page or paragraph by using the Item.[LinkToItem].Fields loop.
Regular pages or paragraphs cannot be selected with this field type, and are greyed out.
Frontend editing of a Link to item field using the Item publisher and Item creator is not possible, and the field will be rendered as a text field. If the system recognizes the text as an external link, it adds http:// in front of the link.
Long text field
With the long text field (Figure 30.1), you get a text area input field for multi-line input.
The long text field has extra parameters (Figure 30.2), when created or edited.
With these parameters, you can:
- Control the visible number of rows in the text area
- Control the visible number of columns in the text area, i.e. the width of the area.
Password field
The password field (Figure 31.1) is similar to a text field, with the exception that the text entered in the field shows up as dots on the screen.
This is, of course, to prevent others from reading the password on the screen.
Product field
With the product field (Figure 32.1), it’s possible to select products from Ecommerce. Basic Ecommerce tags and loops are rendered, so you are able to use them in your layout template, and able to show various details about the selected products.
The product field has an extra parameter (Figure 32.2), when created or edited.
With this parameter, you can:
- Select a paragraph with an ecommerce product catalog attached, in order to control how the product details are displayed.
This is not a replacement for the product catalog, and does not support advanced features like sorting, filtering or search.
Products that are marked as not active/not in stock/have no price are not hidden in the item product page, even if they are set to be invisible in Ecommerce management. But if you click one of these products, you will get a blank page (because the product is hidden due to Ecommerce settings.) In short, be careful with how you use the Product field.
Some Ecommerce loops are not rendered in the layout template when used with the Product item type field, because they are not in the context of a product catalog.
Frontend editing of a product field, using the item publisher and item creator modules, is not possible, and the field will not be rendered.
Rich text field
The Rich text field (Figure 34.1) provides you with a text field and an editor, which makes it possible to format the text in various ways.
The rich text field has an extra parameter (Figure 34.2) when created or edited.
With this parameter, you can:
- Select a custom editor configuration, controlling which formatting buttons are available for the field – you can create custom configurations from Management center > Editor > Editor Configurations area.
Text field
A simple input text field (Figure 35.1), allowing for 255 characters.
User field
With the user field, you can select users or user groups from User Management. Basic user tags and loops are rendered, so that you are able to use them in your layout template, and show various details about the selected user or user group.
Check box, dropdown and radio button lists
These fields make it possible to create lists with checkboxes, radio buttons, or dropdown selectors.
When selecting one of these three list fields, you will see an Edit field options button next to the field type dropdown.
Click this button to choose between three different source types for the list options:
- A static source, where you provide labels and values for the options manually
- An SQL source, where you create an SQL query to provide database fields, from which labels and values are generated for your list options
- An Item type source, which allows you to generate list based content from a specific item type
With the static source, you provide your options manually (Figure 37.2).
A static check box list could look like Figure 37.3.
Radio button and checkbox static source lists have a number of extra parameters in the item field settings, when created or edited (Figure 38.1).
With these parameters, you can style the list options in a grid (Figure 38.2), provided that you have selected an icon for them in the edit field options.
To do so:
- Select where the options label should be rendered
- Select the number of options icons to be rendered on each row (options icon position)
- Specify the maximum width and height for the option icon – if no value is set, the original size will be used
With the SQL source (Figure 39.1), you can write your own SQL query, which then provides you with a dynamic options list.
To do so:
- Write your SQL query in the query field
- Click Execute query to render a list of database columns in the label and value dropdowns
- Select a column for Label and a column for Value
- Click OK
Your SQL generated list could look like this:
With the item type source (Figure 39.3), you can generate list based on content from a specific item type.
To do so:
- Select the item type you want to use item fields from
- Select the item type fields you want to use for the Label and Value
- Specify from where you want to pull your item field data – a website you select, the current website, or items belonging to a particular page (in an item list), or items from the current page
- Decide whether you want to include paragraph items or not, or limit the selection to page items
- Decide whether to include child items, or only include first level items
An item type based list could look like (Figure 40.1).
Checkbox, radio button and dropdown lists won’t be rendered on pages or paragraphs if they don’t have any options defined.
Editable list
With an editable list (Figure 41.1), it is possible for the user to create a custom list when editing an item based page or paragraph.
When creating a new item from the item type:
- Type your list content in the input field
- Click the green plus button
Add content quicker by entering it in a comma-separated format – after you save the item, each value shows up on the correct row.
Grouping fields
You can organize your item fields in groups, which is useful in many scenarios, not least because it allows you to set conditions for showing the field group, and allows the user to collapse a particular group, if it’s not relevant for them.
To create a field group, click New group on your item type ribbon (Figure 42.1).
This brings up the field group settings (Figure 42.2).
With these settings, you can:
- Name the field group
- Create a custom system name – or use the one generated from the name
- Specify if a field group should be collapsible or not – and the default state (collapsed or not). Note that changing the settings will change the collapsed state on the same item type in all instances.
- Specify conditions for showing the field group, based on the values of other fields in the item. For instance, you can have a field group only show up, if option A in a radio button list has been checked – or if the value of a text field matches a specific value.
Editing field settings and deleting an item field
To edit the field settings of a particular page, go to your Management center.
From there:
- Locate the relevant item type on the Management Center tree and click it
- Right-click on the field you wish to edit
- Select Edit field from the right-click menu (Figure 43.1)
To delete an item field, simply click Delete field from the right-click menu.
Item type restrictions
You can restrict the use of your item type, so that it can only be used in the intended manner.
To do so, click Restrictions on your item type ribbon (Figure 44.1).
This brings up the restrictions window (Figure 44.2).
From here, you must:
- Select which websites your item should be allowed for. When a website is selected, the item is available in the templates lists for e.g. pages and paragraphs. If no websites are selected, the item won’t be available anywhere.
- Select the allowed parents of an item type – that is, at what level an item type is able to be created. Allow in root of website makes the item type available at the root level (PageParentID=0), and allow under regular page makes the item type available under non-item type based pages.
- Specify which children are allowed under the item type. You can select Regular page to allow non-item based pages as children, or one of your custom item types (as you can see, we have a lot of item types defined for this website). For an item type called ‘Blog’, it would make sense to only allow child items of the item type ‘Blog post’, for instance.
Remember, that you also restrict item type usage under the Item type settings – read more here.
Item type usage overview
It may be useful for you to have an overview of your item types, and how they are used.
Happy days! That overview is available to you, if you:
- Go to your Management center
- Click Item types on your management center tree
- On your item type ribbon, click Item type usage (Figure 46.1)
This brings up the Item type usage overview (Figure 46.2), where you can see an overview of the places where an instance of an item type exists.
From the overview, you can:
- Filter on item type
- Filter on website
- Filter on where an item is used
It is also possible to get an overview of the usage of a single item type.
Simply click Item type usage on the item type ribbon (Figure 46.3), to see an overview of where that particular item type is used.
Deleting an item type
When you delete an item type, all item data for pages, paragraphs and websites will be deleted, and cannot be restored.
To delete an item type:
- Go to your Management Center
- Click Item Types on your management center tree
- Right click on the item and select Delete
This brings up the delete item type warning dialogue (Figure 47.2).
You can choose to keep your page and paragraph setup, but ALL item data will be removed, and the item based pages and paragraphs will be converted to normal pages/paragraphs.
Make your selection, then click OK.
Implementing
In this section, you will learn about:
- Using context sensitive default values for fields
Context sensitive default values for fields
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). Read more here.
- @User() – get value from the current User object. Read more here.
- @Code() – evaluate C# code
Examples:
- @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)
A very simple example:
You create a new item type – called Blog Post.
The Blog Post item contains an Author field and an author email field.
You want to use the name and email of the current user as the default values of those fields.
To do so, simply:
- Specify @User(Name) as the default value of the Author field
- Specify @User(Email) as the default value of the Author email field
This only works for item based pages and paragraphs and item lists, i.e. not for website and page properties.
Setting a default page or paragraph template for an item type
Item field content is NOT rendered automatically in frontend, so you must customize your page templates using the relevant item related template tags.
Read more about item template tags in the template tag documentation, e.g. for Item.[FieldSystemName], Item.Area.[FieldSystemName], and the Item.Fields loop – and page loops in general.
To set a default template for your item type:
- Click Modules on the accordion
- Go to the Websites module
- Click on the website, for which you want to set a default template
This takes you to the website settings area (Figure 50.2).
On your website settings ribbon, go to the Layout tab (Figure 50.3).
From here, you can click Item page layouts and Item paragraph layouts.
This takes you to the item layouts window (Figure 51.1), where you can select a default layout for your item types.
You can override the default template for an item-based page.
To do so:
- Right click in the item-based page
- Click Properties
- Go to the Layout tab on the page properties ribbon (Figure 51.2
- From here, select the template you want to use – don’t forget to Save the page properties afterwards.
Localizing item fields for the backend
You can localize item type names, item field names, and item field descriptions to match the backend languages of your users.
This is useful if you want to reuse item types across langauge, e.g. if you have monolingual users, or simply users who would prefer to work in their own language.
To do so:
- Go to your Management Center
- Expand your Item Types node and click Translations to bring up your translations overview (Figure 52.1)
- From the dropdown menu, select the item type you want to localize
- Click Add missing translations for this item type
This creates a list of field names and descriptions – depending on the item type fields.
Click either one of these to bring up the localization window (Figure 52.2).
Enter the translated name or description for the relevant languages and click Save or Save and close.
The field will now be marked with a green flag. You can mouse over the flag to see the localized name or description.
Sub-translation keys, like field descriptions, are only translated if a translation exists for the parent key (i.e. the field name).
You can translate inherited item fields as well.
When generating the list of field names and descriptions for an item type with inherited fields, they will be listed in the standard manner, and can be translated in the standard manner.
When rendering the backend, the system will first check for a translation on the actual item type – if it exists, it will be used. Otherwise, if the field is inherited, the system checks for a translation of the field on the parent item type.