Content Query Web Part parameter to XSL Stylesheet


I will add the web part title property just to demonstrate how this can be done. Open your custom content query web part .webpart file and under property "ParameterBindings" add your property so the code would look like:

<property name="ParameterBindings" type="string">
    <ParameterBinding Name="WebPartTitle" Location="WPProperty(Title)"/>
</property>
... where the WPProperty(Title) ... Title is your property. Then go to the /Style Library/Custom Style Sheets/ContentQueryMain.xsl or wherever your ContentQueryMain.xsl is and after to other params add yours ...

<xsl:param name="WebPartTitle" />
... so now the value of the web part title property can be used in both (ContentQueryMain.xsl and ItemStyle.xsl) XSL files as example:

<xsl:value-of select="$WebPartTitle" />
One good reference for passing the CurrentPos in your ItemStyle.xsl here: http://pholpar.wordpress.com/2010/01/21/displaying-results-in-multiple-columns-using-the-content-query-web-part/ Custom Date Formats in SharePoint XSL: http://blogs.msdn.com/b/joshuag/archive/2009/03/25/custom-date-formats-in-sharepoint-xsl.aspx
Posted on

Tags: SharePoint, Content Query Web Part, XSL Stylesheet

Comments