Retrieve all available values “Itemstyles.xsl”
Posted by PANVEGA on April 16, 2009
A good practice to follow when you are going to use some fields from a List or a Library in your ContentQuery Webpart is to retreive all available values.
You can find this file in the document library called ‘Style Library’ in the root of the site collection ( /Style Library/XSL Style Sheets/ItemStyle.xsl ). Open the file in an editor of choice (eg. Microsoft Office SharePoint Designer). Next check it out to be able to make changes to the file.
More about CQWP and Webparts in general follow these links to one of my posts:
http://panvega.wordpress.com/2009/01/07/introduction-in-the-content-query-webpart
http://panvega.wordpress.com/2008/06/03/customize-itemstylexsl-for-contentquery-webpart
At the bottom of the XSL sheet, right before the </xsl:stylesheet>, I put in the following code:
<xsl:template name="ShowValues" match="Row[@Style='ShowValues']" mode="itemstyle"> <xsl:for-each select="@*"> P:<xsl:value-of select="name()" /><br /> V:<xsl:value-of select="." /><br /><br /> </xsl:for-each> </xsl:template>
This comes in handy when you are trying to write custom code in your web part and need the “proper” name of a field opposed to the GUID (e.g. “General Information” would be “General_x0020_Information”). The “P” is the parameter in the case above and the “V” is the value being passed. In some cases the stored field name is differenr from the current presentet value.
This works for any web part that is referencing your new custom Item Style XSL file.
andyburns said
I like to stick a DIV around the items and stick parameters and values onto one line – bit easier to read all the items then!
http://www.novolocus.com/2008/11/11/cqwp-xsl-to-show-you-the-fields-on-an-item/
PANVEGA said
Yes that is a litle bit better to read, writting the paramter and value in one line and adding some div layer around.
Thanks