Custom Field Type Implementation in Sitecore
Mar 17, 2017
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.
About TA Digital
TA Digital is the only global boutique agency that delivers the “best of both worlds” to clients seeking to achieve organizational success through digital transformation. Unlike smaller, regional agencies that lack the ability to scale or large organizations that succumb to a quantity-over-quality approach, we offer resource diversity while also providing meticulous attention to the details that enable strategic success.
Over the past 20 years, TA Digital has positioned clients to achieve digital maturity by focusing on data, customer-centricity and exponential return on investment; by melding exceptional user experience and data-driven methodologies with artificial intelligence and machine learning, we enable digital transformations that intelligently build upon the strategies we set into motion. We are known as a global leader that assists marketing and technology executives in understanding the digital ecosystem while identifying cultural and operational gaps within their business – ultimately ushering organizations toward a more mature model and profitable digital landscape.
Recognized in 2013, 2014, 2015, and 2019 Inc. 5000 list as one of the most successful technology companies in the United States, TA Digital is pleased also to share high-level strategic partnerships with world class digital experience platform companies like Adobe, SAP and Salesforce and possess global partnerships with industry leaders such as Sitecore, Episerver, Elastic Path, BigCommerce, AWS, Azure and Coveo.