Wednesday, June 20, 2007

Adding custom fields to the Enhanced Content Quey Web Part (Beta 1.2)



I just got around to adding another important feature to the Enhanced Content Query Web Part and I uploaded it to codeplex.

I am sure you read my articles, or articles by other MVPS like Heather about showing custom columns in the content query webpart. This requires (as Heather's article shows) that you export the web part to a file, manually modify the file to add the fields you want, and import it back.

This annoyed me enough to add a property to my ECQWP that will allow you to add those fields without having to export-import.




In this version (1.2) you have two new properties in the propeties pane - Data Fields and Common View Fields. I have yet to find out how Data Fields are used, so you don't need to use that property - it is enough that you set the Common View Fields.

I will refer you to Heather's article to find out the format that the value of this property should be written in - how to get the field's internal name, and how to get the field's type. Just a quick reminder though - the value in that field is a pipe seperated value of fields, where each field is a coma seperated pair of field (internal) name and field type.
For example, a text field with internal name "Comments" will be added like so:

Comments,Text

A choice field with internal name "Client_x0020_Name" will be added like so:

Client_x0020_Name,Choice

and if we want to add both of the above fields, it will look like so:

Comments,Text|Client_x0020_Name,Choice





As always, get the web part, installation instructions and source code from codeplex. Just be sure to download the most recent version.








1 comment:

developerx said...

If someone can't get this to work, try using a semi-colon separated list instead of pipe separated, worked for me at least (pipes did not).

The "weird" thing however is that I get an _x005f (code for underscore) added to the names in the XSLT (before the _x0020_). Guess I'll have to implement that somehow tho'.