Wednesday, September 30, 2009

Using Parameter Templates in renderings

This is my first serious attempt at writing something helpfull, so I hope it will be well recieved ;)
A new feature introduced in Sitecore makes it possible to create a data template and use the fields of this template as predefined parameter names for rendering! Personally I like this very much. But how does it work?

For example consider a rendering for a top 5 songs list. That song list can be added on different pages through the page designer by the editors, but they want to be able to choose the genre of the songs that should be shown (rock, pop, country etc.).

Before this we could only add custom parameters to renderings where they were used by both typing parameter name and value, which is not very userfriendly (The editor would have to remember both Parameter name and the allowed values):



When Using Parameter templates the above properties window looks like this instead:



In the above example I have used a Parameter template with three fields, a text field, a checkbox field and a multilist field to show different types of fields can be used.

So How do we make this happen. Very easy:
Create a normal template

Make sure that the template inhirits from the standard template and the System/Layout/Rendering Parameters/Standard Rendering Parameters template. That's what makes the magic happen!

Create the rendering where the Parameter template is needed

Click on the rendering definition item and find the field called "parameters Template" and choose the template.



And voila, it all works!!

Comments about usefullness etc. is very welcome!

2 comments:

  1. Yes, yes, yes.

    Parameters is something we need everybody to use! Thanks!

    ReplyDelete
  2. Parameters are a great idea but I think it's going to be too much for Content Editors to handle :(

    Most.. nay, all, content editors have trouble handling the idea of content coming from multiple items as it is. Asking them to also check the presentation values is going to be too much.

    I have an idea for a potential solution though; if we can use these with edit frames then they can intuitively edit the parameters in the page editor. I think the page editor’s time in the sun has come, no longer just used for the sales pitch and then dropped during development ;)

    ReplyDelete