This blog is very simple and it will concentrate on different type of Fields types which we have in Sitecore. Also Ill explain the some other fields like Source, Shared and Unversioned.
So hope you are enjoying the series and I am able to deliver the content which you need. In case you are looking for something else or have any queries, please get in touch with me from the Contact page.
To learn the field types, we will divide them in different categories and will go through it one by one:
- Date Time
- Drop down
- Multiple Values
These are the common categories we come across and has multiple fields for all these categories.
So to start we will create some custom templates.
- Go to Sitecore (http://learningsitecore/sitecore)
- Enter your credentials (admin/b)
- Go to Content Editor interface.
- Expand Templates item.
- Select User Defined item (/sitecore/templates/User Defined)
- Right click >> Insert >> New Template
- Name the template “Field Types” and Click Next.
- Again click Next and Close.
- Now you will get a screen to create your custom template.
- Lets create the sections based on the Categories we have.
- So what we have done is, we have created 4 Categories in the beginning namely, Text Category, Date Time Category, Check box Category and Image Category.
- Each category has certain fields and field types.
- Text Category – In text we can use Single-Lined Text, Multi-Lined Text and Rich Text field types. As name mentions, single line text will be used for short phrases or titles. Multi lined will be used for fields like Summary which does not need any styling. And Rich Text will be used for the fields like Description which needs styling of the text like making it bold or Italics or adding bullet points, etc.
- It is highly recommended to make minimal use of Rich text fields as it can distort or override the website design or styling.
- Now if you can see there are 3 fields (Source, Unversioned and Shared) for each field.
- Lets understand what are these fields.
By default every field in Sitecore is a versioned field. These fields can have separate language versions and several numbered versions for each language version. To mark a field as versioned do not check Shared and Unversioned check boxes while creating the template.Shared fields
While creating the templates, we need to check the Shared checkbox to make a field ‘Shared’. The data in the Shared fields are shared among all languages and all numbered versions. So if you make a change in one language version of an item it would reflect in other languages and their numbered versions. These type of fields are used mainly if there is some data whose value need not to b versioned at all. Like a profile image or something.
While creating the template, we need to check the Unversioned checkbox to make a field Unversioned. The data in the Unversioned fields are separate for each language version but all the numbered versions share the same data. Select this type of field if you need to maintain different data for different languages but do not need numbered versions. Like a product name field, as it could be different in different languages and you might have decided not to maintain numbered versions.
- So based on the above definitions and our requirements we can use the fields unversioned and shared.
- Now what remains is the “Source” field, this plays different role based on the field types. ex. it is not used in Single line and multi line but is helpful in Rich text fields.
- There are four different types of rich text editor versions which sitecore provides to us, namely Rich Text Default, Rich Text Full, Rich Text IDE, and Rich Text Medium. These 4 versions mean the functionality are enabled based on the version we use. By default it is ‘Rich Text Default’ where we need to add anything in Source field but in case we need to enable any other version then we need to add it in Source field. Please go through this blog to understand how to enable the other versions of Rich text editor.
- Now we have Date Time Category – In this category, we have only 2 field types, i.e. Date and DateTime and as name suggests I don’t think, I will need to explain it. Here we will check how these fields look when we create an item.
- Similarly in the Check box and Image category we have one field type each. Both these fields are self explanatory.
- So lets create a item out of this template and lets check how this fields look.
- Go to Home item (/sitecore/content/Home)
- Right Click >> Insert >> Insert from Template.
- In the pop window, navigate to the Field Types template and in the Item Name, enter ‘Demo1’.
- Click Insert.
- Now if you collapse all the sections then you can see that there are total of 5 sections got created out of which 4 are the ones which we created and other is Quick Info which will be there for each sitecore item.
- Now expand Text Category section and see how all the fields look.
- In the richtext field, we get to insert HTML or we can write plan text and give styling like we do in MS Word.
- Now expand Date Time category section.
- So from the way the fields are rendered here, we can understand when to use Date field type and when to use DateTime field type. Untill and unless the timestamp is not required, you can use ‘Date’ type.
- Expand Check box Category.
- The checkbox is very useful field type and we can just read it as 1 or 0 in backend.
- Expand the Image Category.
- Browse helps you to browse the Image in media Library or upload it and select the Image.
- This completes our 4 categories out of 7 we mentioned above.
Since I don’t want to stretch everything in one blog which becomes boring, so I will split this topic into 2 blogs and explain the remaining 3 categories in the other one.
Thank you.. Keep Learning.. Keep Sitecoring.. 🙂
2 thoughts on “What are different types of Field types in Sitecore? – Part I”
Pingback: What is template and how to create it? | Sitecore Dairies
Pingback: What are different types of Field types in Sitecore? – Part II | Sitecore Dairies