In part 1 of this series Introduction to Sitecore Parameter Templates: Making sublayout configuration more intuitive we looked at the advantages of using parameter templates

For the context of this article I will be working on a simple online department store, with multiple departments.

I want to create a Sublayout that can be used on a department homepage, I want the Sublayout to display the latest promotions relevant to the department, I also want to be able to configure the behavior of the Sublayout after it has been created without writing code or editing global settings fields that would affect all instances of the Sublayout, in short it needs to behave differently for each department and it needs to be easily configurable.

As previously mentioned in part 1 we could use the “Additional Parameters” field to generate a NameValueCollection but this doesn’t help future users of the Sublayout to know what options are available to them and it does not provide us with a mechanism to restrict the values entered.

namevaluecollection

 

So let’s be more explicit about what options we can have, what their types are and let’s provide an appropriate user interface to make those choices. Sounds like a Sitecore template doesn’t it?

Sublayout parameter templates are applied on individual Sublayouts by first selecting the Sublayout and then selecting the Content tab, these parameters will then be available wherever the Sublayout is used. By default the parameters will be configurable in the Page Editor, to disable this uncheck the Editable option.

parameterstemplate

Our Sublayout parameters template then behaves like a regular Sitecore data template but with one important difference. Your template must inherit from…

/sitecore/templates/System/Layout/Rendering Parameters/Standard Rendering Parameters

…instead of the normal Standard template, if you do not do this you will be prompted with an error message when you try to edit the Sublayout. So our finished Sublayout parameters template looks like this:

finishedtemplate

So you can see we are providing options to limit the number of promotions displayed as well as a mechanism for only showing the promotions in certain date ranges or months. So now we can modify presentation details on the individual department items and take advantage of these new options.

This can also be done by content authors using the Page Editor by selecting the Sublayout, clicking the more button and then selecting the “Edit the Component Properties” option.

So what if we edit the configuration of a Sublayout on an item and the item template’s presentation details are updated on the standard values afterwards, related links were removed for example. Won’t the item not receive the changes? Yes and no, in Sitecore 6.4.0 rev.101012 layout deltas were introduced, which allows us to partially update an item’s presentation details without breaking inheritance on the Sublayouts/Renderings that were not changed, prior to this that assertion would be correct so this is a caveat to be aware of.

In the next installment of this series, we will look at how best to retrieve the Sublayout configuration values in our  codebase.

Tagged with:
 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>