Although, I am sure all reader know this very will but here
wanted to add some key points.
Rendering parameters can be used to pass parameters to
sitecore presentation components. Basically tey are used to control the
presentation of the component by these parameters.
Key benefits:-
1.
No need to maintain content separately.
2.
Easy to use.
3.
Real feature of WYSWIG editor.
4.
Editorial team love it.
5.
Design at the design time and multiple variant/combination
can be easily verified.
Steps-
Create a rendering.
Create a template and add appropriate fields like size ( Single line text) and Heading (Siingle Line text)
Change the base tempalate to standard rendering parameters.
Create a template and add appropriate fields like size ( Single line text) and Heading (Siingle Line text)
Change the base tempalate to standard rendering parameters.
Now go to rendering section and provide the reference of this template.
Now if we go to experience editor, this parameter will be there, Add the rendereing parameter values.
These values can be consumed on the rendering by simply below code.
@using Sitecore.Web.UI.WebControls;
@using Sitecore.Web;
@{
string heading = string.Empty, test = string.Empty;
var renderingParam = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull;
if (renderingParam != null)
{
var parms = renderingParam.Rendering.Parameters;
heading = parms["Heading"];
test = parms["Test"];
}
No comments:
Post a Comment