Tag Archives: webpart

Post navigation

There are several ways to skin the Webparts deployment cat, each with a few pluses and minuses. Thanks to Mark Harrison we have have a quick and pragmatic list of the options, complete with instructions.

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:

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.

Add a Content Query Web Part to a page. * In the Query section, set the Source to show items from the Knowledge Base Articles document library (list). Set the list type and content type accordingly.
* In the Presentation section, set the Item Style to Title and description. 2.

Edit the properties in the Web Part file to display custom fields. To access the .webpart file for the Web Part, on the Web Part’s edit menu, click Export. * Office SharePoint Server 2007 generates a .webpart file with the complete set of properties that are available for this Web Part. The .webpart file is an XML file that you can edit using a text editor. 3.

In the .webpart file, locate the CommonViewFields property. Use this property to specify the additional fields you want to display in the Web Part. Add the internal names of the columns and the type.
Copy Code

KB_x0020_Title,Text;Product,Text;

NoteNote:

You cannot use your columns’ display names in this property. You can find the internal column names by checking the properties of the column in the list or document library. Right-click the column, and then click Properties. The internal name of a column appears in the Address (URL) property after ‘Field=’. In the Knowledge Base Articles scenario, the columns are Knowledge Base Article and Product and their internal names are KB_x0020_Title and Product, respectively. 4.

Map these internal column names to the columns’ Title and Description present in the XSLT transformations. To do this, edit the DataColumnRenames property.
Copy Code

KB_x0020_Title,Title;Product,Description
NoteNote:

The default XSLT transformations can render the following four fields: Title, Description, LinkUrl, and ImageUrl. In your DataColumnRenames property, verify that the names you specify match the names in the XSLT transformations; that is, Title, Description, LinkUrl, and ImageUrl. 5.

Save the .webpart file locally. 6.

In the Web page, delete the Content Query Web Part you added in step 1. 7.

Import the .webpart file and add the Web Part to your page. To import the .webpart file, click Page, click Add Web Parts, and then click Import. Browse to the .webpart file, and then click Upload. 8.

Drag the Web Part to the appropriate zone in the page. The Web Part should display the Knowledge Base Title and the product name.

Requests additional fields, which is necessary because the Content Query Web Part does not return all fields for all items automatically. You must request fields to render in an XSLT transformation.

This property is additive, meaning that you can add more than one CommonViewField to a Content Query Web Part and extend its base properties, such as FieldDescription and FieldTitle.

QueryOverride

Bypasses limits to query behavior imposed by the Content Query Web Part UI. Makes it possible to specify the query portion of a cross-list query in CAML.

When the QueryOverride property is set, the UI for filtering, sorting, and grouping appears dimmed in the tool pane. For example, by default the Content Query Web Part allows three filters, and you might want to add more and ensure that the customized fields and behavior persists in the UI.

WebsOverride

Determines whether the cross-list query should recurse subsites. By default, Office SharePoint Server 2007 recurses subsites, meaning that the parent site and its child sites are displayed.

When the WebsOverride property is set, the Content Query Web Part does not recurse, and displays results from only the specified site.

ListsOverride

Overrides the list behavior in Office SharePoint Server 2007, and supports several types of lists, such as Page Libraries, the General List base type, and specific list types. You can use this custom property to set any list type, even those not enumerated in the UI because the template is not defined at the root or is a base type.