Monday, October 17, 2016

Rendering Parameters

Note !!! I have moved my blog to https://pramisoni.wordpress.com/ . Please Visit https://pramisoni.wordpress.com/ for old and new posts.

Hi Friends.
Everyone must be aware of the concept in Sitecore called "Rendering Parameters" and many of use must be using in day to day development activity.
This is my first blog post as an individual blogger :-)
So starting with a very basic and simple idea.
Rendering Parameters are used to control the presentation of a rendering/ component. Rendering parameters should be used if you want to make it possible to change anything related to the presentation and not the component content.
An example can be a Banner component that has a Title, Text and Image, but it should be possible for the editor to control the text color and the alignment of the text. The Title, Text and Image data has to be stored on the data source item and the text color and the text alignment has to be controlled using rendering parameters, as they change how this component is presented to the user.
So Let's now get into demonstration
Sitecore structure and templates
To use rendering parameters, the first thing you need to create is a new template with the fields you need to control the presentation of your component. Example, “Space deck” and “Color Deck”
Let's give name as DeckRenderingParameters





In addition to this, you need to make sure the template inherits from "/Sitecore/templates/System/Layout/Rendering Parameters/Standard Rendering Parameters" instead of the "Standard template".
It's always good to create rendering parameter with the name of the suffix “Rendering Parameters”. Here I am using a name as DeckRenderingParameters. Use a field type should depend on upon the requirement. Here I am using “droplink”
Now the second step, define this template to controller rendering where you want to apply rendering parameter option. In controller rendering, there will an option called “Parameter Template”. Add “DeckRenderingParameters” template full path to “Parameter Template” field.



After following all the steps, you should be able to see both the option in rendering parameter. So here you can see using Droplink as filed type is having the advantage to choose options as dropdown values.


Again this is just an example I gave for rendering parameter. There so are many things you can do with rendering Parameter.









No comments:

Post a Comment