Thursday, June 14, 2018

Rendering parameters

var rc = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull;
            if (rc != null)
            {
              var parms = rc.Rendering.Parameters;
                Item clpLoginFieldItem = Sitecore.Context.Database.GetItem(ClpLogin.Fields.ClpLogin);
                var show = parms[clpLoginFieldItem.Name];

                if (show == "1")
                {
                    string test = "true";
                }
            }



var parms is actually a string. In my case I  only had one parameter but it was a checkbox. And it was not checked. Therefore the parms was null. Otherwise var show = 1


Template for this is System > Layout > Rendering Parameters > Standard Rendering Parameters.

Go to a rendering. Select this template in the Rendering Paramters field.

Verify it on the rendering in presentation details on a navigable item.

No comments:

Post a Comment