DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

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:

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 />

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.


2 Responses to “Retrieve all available values “Itemstyles.xsl””

  1. 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!

  2. 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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: