I have been working on a new web part that aggregates content of a specific content type into a gridview. Much like the Content Query web part, but easier to use by end-users. They just need to select the content type and the columns they want to be displayed (that’s why I called it “Content by Type”).
The most important features are:
– Works in WSS and MOSS
– Casting / formatting of column data types
– Links to items and its context in contextmenu
– Links to lookup / person fields
– Filter items using MOSS filter web parts
– Supports grouping/sorting and paging
The screenshot above shows the Content By Type webpart in action. The view displays 4 columns of this content type. The view is grouped by content type and sorted by Modified date. When configuring the webpart, users simply choose a content type and the web part lets them pick the columns they want. The screenshot below shows part of the configuration. Users can (un)select the available content type fields and configure the links for these fields. After configuring the other web part properties (scope, grouping, sorting, list type, etc.) the web part will query for items that match the selected content type(s) and display the results in a grid.
Below you will find a brief description of the most important features. The webpart is currently in beta.
PLATFORM
The Content by Type web part works on both Windows SharePoint Services 3.0 and Office SharePoint Server 2007. This introduces content aggregation to WSS sites. The out of the box Content Query webpart is only available in Office SharePoint Server.
Technical info: Before querying the web part decides if it is running in a WSS or a MOSS site. If the feature called “Office SharePoint Server Publishing Infrastructure” is activated for the site collection, it is considered to be a MOSS site. In that case the CrossListQueryCache object is used to query. In WSS sites, the SPSiteDataQuery object is used.
FORMATTING
Data returned by the Content by Type webpart is casted and formatted as the datatype of the column. The formatting options that are applied to the site columns (currency, number of decimals, datetime format, etc.) are also applied to the query results. SharePoint items displayed by the Content by Type web part therefore look the same as items displayed by the SharePoint views. Casting the data to the correct datatype is also important for sorting. This ensures that when a user clicks a column header of a datetime field that the data is sorted like a date.
ITEM LINKS
For every list item returned by the Content By Type webpart, 3 links are automatically generated. While configuring the webpart, these links can be recognized by a ‘(*)’ in the displayname of the fields in the user interface. These links can be displayed on every field. These links are availble:
• Link to item – a link to the details page of the item/document. This is especially useful for documents. SharePoint normally automatically renders the link to the document itself. Getting to the information stored in the metadata of the document is now easy by using the “Link to item” field.
• Link to item (with menu) – a link to the details pageof the item/document with a dropdown menu:
These menu options can be used to navigate directly to the site or the list that contains the item or document. This makes it much easier for users to get an idea of the context in which the item was published.
• Name Link – a link to the document itself (only available in content types with a “File” column (eg document content types).
LOOKUP AND PERSON OR GROUP FIELDS
If the content type contains Lookup or Person or Group columns, the content by type webpart automatically adds a “linkfield” to the list of available fields. When selecting columns to be displayed, the user can choose to select a link for these fields.
When the items are displayed, these columns now have a link to the person/group or the lookup item. This also applies to the out of the box Modified By and Created By fields.
FILTERING
Office SharePoint Server offers a set of different filter webparts. They all can provide filter values available from different sources to other web parts. The Content by Type webpart supports incoming filters from these filter web parts. In the screenshot below the user has selected “Americas” in the choice filter. This SharePoint filter web part is connected to the Content by Type web part, filtering the Region field.
When connecting the filter web part to Content by Type, you can select the content type field on which you want to filter. The can be any field of the content type, not necessarily a field that is displayed in the grid. When you connect a multivalued filter webpart, all values are handled as an “OR” in the CAML query.
Please note: In the first release filters are limited to MOSS, because of the absense of filter webparts in WSS. The other limitation for now is that you can only connect 1 filter webpart.
PAGING
When configuring the web part, users can set up the maximum number of items that will be returned by the web part. They can also edit the pagesize.
GROUPING AND SORTING
The Content by Type webpart supports grouping and sorting. When configuring the webpart, users can select a field to group by. They also can select the initial sort field and sort order. The sort order can be changed by clicking the column headers.