Rendering Parameters

Similar to modelling templates you are able to model rendering parameter templates. While the rendering parameter templates in Sitecore are effectively the same as your standard templates the way the data is stored is different. Due to the fact rendering parameters aren’t actually items and the values are stored in the presentation details you will need to use different base classes and interfaces. Generally it is best to stick with simple field types when using rendering parameters and therefore Fortis comes with a reduced number of field types that can be modelled compared to the standard templates.

Key points

  • Interfaces modelling rendering parameter templates must implement IRenderingParameterWrapper
  • Classes implementing your interfaces must inherit the class RenderingParameterWrapper
  • Each interface created needs a TemplateMapping attribute added to it and need the extra parameter of “InterfaceRenderingParameter”
  • Each class created needs a TemplateMapping attribute added to it and need the extra parameter of “RenderingParameter”
  • Use the GetField(“Field Name”, “Field Type”) method for returning strongly typed versions of the fields
  • Fields use the same interfaces as standard templates but have different classes (Fortis.Model.RenderingParameters.Fields)
  • Rendering parameter fields don’t implement everything on the interfaces, for example you can’t use the Render() method because there’s no underlying Field to be rendered.

Let’s assume we have the following rendering parameter template in Sitecore;

  • Container Options
    • Border – Checkbox
    • Border Colour – Droplink
    • Border Thickness – Integer
    • Border CSS – Single-Line Text
[TemplateMapping("{AAA421D9-53C1-443B-AB8C-0499110138D8}", "InterfaceRenderingParameter")]
public partial interface IContainerOptions : IRenderingParameterWrapper
{
	IBooleanFieldWrapper Border { get; }
 	ILinkFieldWrapper BorderColour { get; }
 	IIntegerFieldWrapper BorderThickness { get; }
 	ITextFieldWrapper BorderCss { get; }
}

[TemplateMapping("{AAA421D9-53C1-443B-AB8C-0499110138D8}", "RenderingParameter")]
public partial class ContainerOptions : RenderingParameterWrapper
{
	public ContainerOptions(Dictionary<string, string> parameters, ISpawnProvider spawnProvider) : base(parameters, spawnProvider)
	{
	}

	public virtual IBooleanFieldWrapper Border
	{
		get { return (Fortis.Model.RenderingParameters.Fields.BooleanFieldWrapper)GetField("Border", "checkbox"); }
	}

	public virtual ILinkFieldWrapper BorderColour
	{
		get { return (Fortis.Model.RenderingParameters.Fields.LinkFieldWrapper)GetField("Border Colour", "droplink"); }
	}

	public virtual IIntegerFieldWrapper BorderThickness
	{
		get { return (Fortis.Model.RenderingParameters.Fields.IntegerFieldWrapper)GetField("Border Thickness", "integer"); }
	}

	public virtual ITextFieldWrapper BorderCss
	{
		get { return (Fortis.Model.RenderingParameters.Fields.TextFieldWrapper)GetField("Border CSS", "single-line text"); }
	}
}

Next: Search