Custom Field Type Implementation in Sitecore
Dec 25, 2013
Consider the following requirement: A company has several products and each product has several sub-types called grades. Each grade has several properties, some of them specific to the grade. It is required to load grade and property data into Sitecore and be able to display the grades and their properties for a selected product.
An elegant way to implement this requirement is by developing a custom field type that can store the different, multiple properties passed in as parameters. These properties can then be retrieved by referencing a single item rather than having to access several items. An outline of the solution is presented below.
Step 1: Create a .NET class for field type
The class name will be the field type name. We inherit from Sitecore.Web.UI.HtmlControls.Control as the base class.
Step 2: Custom field type implementation
Write the code to process the properties, separated by a delimiter, and render them as individual fields as shown below.
The grade properties values will be stored as name value pairs separated by ‘=’.
Step 3: Add config file
Create the required configuration file in App_Config\Include folder to reference the custom field type by its class.
Step 4: Create a new Field in Sitecore
Create a new field type based on the template “Template field type” in the Core database and specify the “Control” field to refer to the class name in Step 1.
Step 5: Add field belonging to the new field type on a template and create item
The new field type then works similar to any built-in type in terms of specifying it on a template.
If you would like more help on Sitecore Custom Field Type Implementation Contact Us Today.
Explore Additional Resources
Learn how you can select the best Digital Experience platform for your business.
Our Certified Sitecore Experience Platform and Sitecore MVP’s specialize in helping you deliver seamless contextually personalized customer experiences.
About TA Digital
TA Digital is an innovative digital transformation agency, specializing in delivering the digital experience, commerce, and marketing solutions. For nearly two decades, we have been helping traditional businesses transform and create dynamic digital cultures through disruptive strategies and agile deployment of innovative solutions.