What are different types of Field types in Sitecore? – Part II

So this blog will be the continuation of the previous blog, where we completed the first 4 categories and now we will concentrate on the remaining 3. Those categories are:

  1. Link
  2. Drop down
  3. Multi values

So to start learning these categories, we will need to create one more custom template. By now I am sure, you know to create a custom template. SO lets do it once again.

  1. Go to Sitecore (http://learningsitecore/sitecore)
  2. Enter your credentials (admin/b)
  3. Go to Content Editor interface.
  4. Expand Templates item
  5. Select User Defined (/sitecore/templates/User Defined)
  6. Right Click >> Insert >> New Template
  7. Name it “Field Types2” and Click Next
  8. Again click Next and Close.
  9. Now you will get a template creation screen.
  10. Lets create 3 sections for different categories and different field types under each category.
  11. Now we have created 2 Categories – Link Category and Drop Down Category
  12. Lets create Multi value category as well.
  13. Now I will deep dive in each and every field.
  14. For Link category, we have 2 types of fields type – internal link and General link.
  15. As the name states, we can use internal link only when we are sure that we will be redirecting the user within the site like Home, About, Services, Contact us, etc. We can use General link when we are not sure whether it will be internal link or External link or mail to function like in the case of CTAs.
  16. For Drop down category, again we have 2 field types – Droplink and Droplist. To understand it better, please go through below write up and I will explain this when we create dummy site.
    Droplist field type:
    The value is stored in Sitecore as plain text representing the display name of the selected item. In this case you could use your code sample to render out the name of the selected item (if that’s really what you want to do).
    *Note that the content editor will use the Display Name of the items in the droplist, but your code would render out the item name. This is not a good practice as it is not possible to translate item names.DropLink field type:
    The value is stored in Sitecore is an ID of the linked item. In this case you would need to get the selected item using this ID, then render out the required field of that item. I would probably write a code-behind method to get the selected item.
  17. Don’t need to stress yourself, both the field types does the same thing, helps you select single item from the list of items. But it further differs if you need the item Name or you need any other field from the selected item.
  18. Now as we are discussing about selecting a single item from the list of items, how will the drop down fields know which list to display?
  19. For that we have a “Source” field in front of each field type.
  20. Lets give Menu as the list of items to both the drop down fields.
  21. Lets note the path of Navigation folder (/sitecore/content/Home/Navigation).
  22. Now the value of path, we will paste in Source field of both drop down fields.
  23. How it is rendered in item we will check once we are done with our 3rd category.
  24. In the multi value category, we have 5 different field types namely CheckList, Multilist, Multilist with Search, TreeList and TreeListEx.
  25. The purpose of all the field types is same, to allow you to select multiple values from the list of items. The difference is the way this fields are rendered in the item.
  26. Since we need list of items, we will enter the path of Navigation in Source field of all fields. But for add Source field for Mulitlist with Search, it is bit different.
  27. We should note the id of Navigation folder ({31C1994A-3AB9-4CF0-8A26-32CAC7E8FAA6}) and Id for the MenuItem template ({AE6600D5-5C68-4D7C-9674-D29E34D2BF7C}) as all the Menu items (Home, About, Services, etc are based on MenuItem template).
  28. The source field content will be “StartSearchLocation={31C1994A-3AB9-4CF0-8A26-32CAC7E8FAA6}&TemplateFilter={AE6600D5-5C68-4D7C-9674-D29E34D2BF7C}”
  29. The ids in my blogs and your instance can be different. So the id of your navigation folder will come in StartSearchLocation and your MenuItem template’s id will come in TemplateFilter.
  30. Now that we are done with template. Save the changes.
  31. Lets create a content item based on this item and check.
  32. Go to Home item (/sitecore/content/Home)
  33. Right Click >> Insert >> Insert from template
  34. Navigate to the “Field Type2” template and give Demo2 as Item Name.
  35. Click Insert.
  36. Now we have 4 sections out of which we have created 3 sections and 1 is Quick Info where we can get Id, Name, Template id and Path of the current item.
  37. Lets see Link Category section.
  38. Now if we see, for Internal link we get only 2 options to insert link and clear and for General link we get different options to select the link.
  39. Lets see the drop down category section.
  40. Both the fields render same way and we can’t see the difference. But the difference is when we will try to get the selected item in the back end. One will give us a plain text and other will return us an item so we can get value of any field of that particular item. We can see that while building the site.
  41. Lets see the Multi value category section.
  42. So these shows how the different field types are rendered. All gives you a same functionality of selecting multiple items from the list of items but the way of representing it is different.

    This completes our part II of the field types. Hope you are not bored with the series and we will see something called standard values in our next blog.

    Thank you.. Happy Learning.. Happy Sitecoring ๐Ÿ™‚

3 thoughts on “What are different types of Field types in Sitecore? – Part II

  1. Pingback: What are different types of Field types in Sitecore? – Part I | Sitecore Dairies

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s