Over the last few months I have had to configure various Content Query Web Parts (CQWP) to provide portal rollups that can be pre-packaged and re-configured in the SharePoint UI instead of having to use SharePoint Designer when using Data View Web Parts.
I could go into the basics of setting up a CQWP, but since others have done it for us I’ll just provide some link love here. Even though this post if fairly old it provides a TON of value for those getting started with the CQWP, but the main thing I find missing is how to identify the items needed in the CommonViewFields property. You can find the internal field name pretty easy by going to your list settings, and then look at the URL when you hover over the column you want to identify. The Field Query String parameter gives you the internal name you need.

Now that you have the internal name for the columns you need, now you need the column type. I haven’t been able to find a decent resource for all of the column types, so I figured this is where I needed to list them all out:
|
Display Column Type
|
Internal Column Type
|
|
Single line of text
|
Text
|
|
Multiple lines of text
|
Note
|
|
Choice
|
Choice
|
|
Number
|
Number
|
|
Currency
|
Currency
|
|
Date and Time
|
DateTime
|
|
Lookup
|
Lookup
|
|
Yes/No
|
Boolean
|
|
Person or Group
|
User
|
|
Hyperlink or Picture
|
URL
|
|
Calculated
|
Calculated
|
Of course these are all the default column types you can create, however there are some others, like the Publishing columns such as:
|
Display Column Type
|
Internal Column Type
|
|
Publishing Image
|
Image
|
|
Publishing HTML
|
HTML
|
Another nice way to see what these values are would be to use PowerShell. I will often drop into PowerShell and look at the fields in a specific list to view the internal name, along with other variables, the following lines will output a table of all fields associated with a list and the Display Name, Internal Name, Display Column Type, and the Internal Column Type:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$site = new-object Microsoft.SharePoint.SPSite("http://moss150")
$web = $site.OpenWeb()
$list = $web.Lists["CQWP"]
$list.Fields | Format-Table Title, InternalName, TypeDisplayName, TypeAsString

Having these items should now set you up to have all the information you need to customize your Content Query Web Part. Just create a customized template in the ItemStyle.xsl (or create your own custom XSL file and link to it using the ItemXslLink property in your .webpart file) to render the information you need and you should be ready to start utilizing the infamous Content Query Web Part.

["Brian"]
NOTE: If you are going to use any of the ddwrt commands that you might be used to using SharePoint Designer to format dates and such, make sure to include the appropriate stylesheet in the header of your XSL file:
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
Posted
12-01-2008 1:36 PM
by
Brian Caauwe