Sitecore XM & XP

Use model builders

Canvas Sitecore integration allows to define a model builder for component. It can be helpful when item fields isn't enough and we need to prepare data from back-end side.

Implement Uniform.ModelBuilders.IModelBuilder, Uniform.ComponentModel interface

datasourceItem - current datasource item (can be the same as a page item)
<result> - json-serializable object

Register model builder via Sitecore config

@uniformdev/canvas-sitecore package contains a few helpers to work with model builders.

  • getModelOrItem function

  • getPageItemId function

  • create an enhancer from createItemEnhancer function

  1. In Visual Studio, create a new project

    • Project template: Class Library (.NET Framework)
    • Framework: 4.6.2+
  2. Add the Sitecore NuGet repository as a package source in your solution.

  3. Add the Uniform NuGet repository as a package source in your solution.


    Contact our support team for a link to this repository.

  4. Add a reference to the following packages:

    • Sitecore.Kernel
    • Uniform.ComponentModel

Implement Sample Rendering model and model builder

Register Sample Rendering model builder

Create App_Config\Include\zzz_MySite\MySite.Uniform.Canvas.config config with the following content

Update enhanceComposition function

Uniform.ModelBuilders.ItemFieldsModelBuilder, Uniform.ComponentModel allows to build simple models without custom code.

Model builders may have implicit Sitecore item dependencies. In order to support incremental cache purge for Data Types, we need to define such kind of dependencies explicitly.


You can skip this step if you don't intend to utilize Data Types.


This functionality requires latest v7.2-patch-2 version of the Uniform connector (Sitecore package named Uniform Canvas v7.2.230517-1 Upgrade Package for UFS v7.2) which needs to be installed on top of previously installed v7.2 or v7.2-patch-1 (Sitecore package named Uniform Canvas v7.2.23XXXX for Sitecore 8.2.0-10.3.0). If you use .NET SDK please make sure to update your dependencies as per packages.config

Use Uniform.Models.ModelBuilderResult, Uniform.ComponentModel as model builder result