Send Web part property to Xslt

08/12/2012 07:22

1. Define querystring in .webpart file
 <property name="ParameterBindings" type="string">&lt;ParameterBinding Location="WPProperty(category)" Name="CategoryProperty"/&gt;</property>

 

or equivalent in .aspx file

<ParameterBindings>

    <ParameterBinding name="CategoryProperty" Location="WPProperty(category)"/>

</ParameterBindings>

 

2. Add parameter to ContentQueryMain.xsl
 <xsl:param name="CategoryProperty"/>

 

3. Use it in ContentQueryMain.xsl

From query string: <xsl:value-of select="$CategoryProperty"/>

 

so if you have

<property name="category">MyCategory</property> in .webpart file, $CategoryProperty=MyCategory

 

Note: No queryString or 'categoryProperty' is visible in source xml by using Identity transform. They are visible only when you force it e. g. by:

<xsl:value-of select="$categoryProperty"/>