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.

custom field type

 

 

 

 

 

 

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 digital transformation agency that helps organizations realize immediate and long-lasting value through exceptional user experience and data-driven methodology. For nearly two decades, we have been helping clients overcome the lack of scale and resource diversity of small regional agencies and the quantity-not-quality approach of large system integrators. We are known as a global leader that helps marketing and technology executives understand the digital ecosystem, identify operational gaps within their organization and finally ushering them into a more mature and profitable digital landscape.

TA Digital has high-level strategic partnerships with digital experience platform companies like AdobeSAP and Salesforce. TA Digital also has global partnerships with industry leaders like SitecoreEpiserverElastic PathBigCommerce, AWS, Azure and Coveo. The company was also recognized in 2013, 2014, 2015, and 2019 Inc. 5000 list as one of the most successful technology companies in the United States.