- Sitecore Cookbook for Developers
- Yogesh Patel
- 294字
- 2021-07-16 11:15:00
Creating strongly typed rendering parameters
In the previous recipe, you learned using additional parameters, but these are loosely typed. So, chances are that content authors may enter invalid values such as non-numeric values for the RecordsCount
parameter and a style class in CssClass
that does not exist, and so on, which can lead to misbehavior of the application. Now, just imagine how happier your content authors will be if they see strongly typed parameters such as checkbox, integer, droplist, and so on.
In this recipe, we will use the Integer
field for RecordsCount
and a Droplist
field for CssClass
so that we always get valid values from the input.
Getting ready
Create a Stylesheet Class
template and create different items outside the Home
item, as shown in the following image. We will use the CssClasses
folder as a source of the droplist field.

How to do it…
We will first create a template with the required input parameters as its fields:
- Create a
List Rendering Parameters
template, set/sitecore/templates/System/Layout/Rendering Parameters/Standard Rendering Parameters
as its base template, and create the required fields as follows: - Select the Simple List view rendering that we created in the previous recipe. In its Parameters Template field, select the parameter template that we just created:
- Now, select the component from either the Experience Editor or Content Editor, and open component properties. You will find strongly typed parameters that we just created, as shown in the following image:
- Remove these additional parameters from component properties. Additionally, if you have changed the parameters' names here, then make sure that you update in the
ItemList
model too. - Preview the page; you will see how your own parameters are working.
- Vue 3移動Web開發與性能調優實戰
- Learning NServiceBus(Second Edition)
- 深度實踐OpenStack:基于Python的OpenStack組件開發
- What's New in TensorFlow 2.0
- React Native Cookbook
- OpenCV for Secret Agents
- Bootstrap Essentials
- 從學徒到高手:汽車電路識圖、故障檢測與維修技能全圖解
- SQL Server 2016數據庫應用與開發習題解答與上機指導
- 測試架構師修煉之道:從測試工程師到測試架構師
- UI設計基礎培訓教程(全彩版)
- Spark技術內幕:深入解析Spark內核架構設計與實現原理
- ASP.NET本質論
- Python機器學習
- JavaScript程序設計實例教程(第2版)