Friday, April 16, 2010

Sitecore Rendering Parameters – Friday Gotcha


One of the things I’ve learnt today is that Rendering Parameters is an extremely cool feature of Sitecore .NET CMS. It really empowers your editors by giving them ability to tweak parameters of your renderings in a very easy and intuitive way.

You can simply have any Sitecore field rendered within the Control Properties dialog just like in Content Editor.image
And you can then access it as an ordinary parameter within rendering, for example within XSL Rendering:
<xsl:param name="type"/>
<xsl:param name="username"/>

The idea is simple and beautiful. You create a template where you add those fields, then you assign that template to a rendering via the “Parameters Template” field:image
While this is all great, I discovered today is two things today.
First, when assigning a Rendering Parameter Template to a Rendering, make sure that template is inherited from the following template, otherwise it would not work, and you will get an error. /sitecore/templates/System/Layout/Rendering Parameters/Standard Rendering Parameters image
Second thing I’ve learnt about this feature is that the parameters that are being passed to your Rendering are case sensitive. In other words, if the field names on the template are “Type” and “Username”, you will need to specify your parameters accordingly:
<xsl:param name="Type"/>
<xsl:param name="Username"/>

Things may be different for sublayouts and web controls, but you tell me :-)
Read more about rendering parameters here.

5 comments:

Kamsar said...

They're cool but it would be nice if they were taken a step further: they don't support localization (because the layout field is shared), and the interface to edit them is still a bit buried to the average CMS user.

That said, they have the potential to make the Page Designer so much more than it is - to let CMS users attach arbitrary bits of both presentation and content to a page in a single shot.

It'd be nice if that exception from inheriting from the wrong template was more informative too - that one got me the first time I tried to use them :)

zebudevelopment said...

Hi Alex, i hear that you had a nice presentation about Sitecore Search at Dreamcore . Do you have a public paper? Best regards, Vlad.

Chen Hendrawan said...

@Kamsar,

I believe you that layout field is shared, but do you have official Sitecore documentation to backup this information?

I know it is an old post, but I need to ask anyway.

Thanks.

J Wheelock said...

Hey Alex,

Any idea how to access Rendering Parameter Fields of a sublayout from a nested xslt rendering? I'm rendering the transformation using the control directly in the sublayout.

- Josh

J Wheelock said...

Hi Alex,

Any idea how to access Rendering Parameter Fields of a sublayout from a nested xslt rendering? I'm rendering the transformation using the control.

- Josh