Create Rendering Parameters in Sitecore MVC

Posted 09/19/2016 by Yogeshwer Sharma

While working on pagination control I got a requirement to create rendering parameters on rendering so that we can easily handle the values like enable pagination, ResultOnPage and others from rendering itself and from page editor.

Let me start with what are Rendering Parameters in Sitecore: 

Rendering parameters can be used to pass parameters to sitecore presentation components. They are used to control the presentation of a dynamic component from page editor.  

In the below example I’ll demonstrate to how to create rendering parameters and how we can read those parameters in code.

Create Rendering Parameters in Sitecore - 

  1. Create a data template under /sitecore/templates/ or any location where you want to have that template. I have created a folder template with name Rendering Parameter and under that template created new template with name _paging.



  2. Create fields on that template which you want, in my solution I have created two fields   - You can create any fields with any name which you want to use as rendering parameters.

    1. Enable  - Checkbox type
    2. ResultsOnPage – Single-Line-Text



  3. Inherit the Standard Rendering Parameters template under /sitecore/templates/System/Layout/Rendering Parameters/Standard Rendering Parameters location.



  4. Select the rendering Item on which you want to use these custom parameters and navigate to Parameters Template field which is in Editor Options section.



  5. Now apply this rendering to the content item and open rendering properties you can see fields on rendering which you created in data template.



  6. You can provide values in these fields.

How to read the Rendering Parameter value in code – 

My solution was in MVC so I got these values in controller with the help of below code – 

var enable = RenderingContext.Current.Rendering.Parameters["Enable"];

var ResultOnPage = RenderingContext.Current.Rendering.Parameters["ResultOnPage"];

The main advantages of rendering parameters are we can easily manage/handle dynamic values from page editor.


Add your comment