Skip to main content

Features

Go Search
Home
Blog
Content By Type
Alpe d'Huzes
  

Other Blogs
There are no items in this list.
Ton Stegeman > Content By Type > Features
New configuration editor

Version 1.2 of the Content By Type WebPart contains a new configuration editor. Instead of trying to squeeze all configuration in the toolpane, I decided to create a popup window. You can launch the editor by clicking the link in the toolpane:

image

In the screenshot below you can see a screenshot of the editor in action. The webpart is configured to rollup all task in the site collection and display them in a grid.

image

Configuration of the webpart is done in a number of steps:

  1. Datasource options
    In the Datasource options section of the editor, you can select a content type and configure some other options that help to define the search query:
    • Include descending
      If you check this box, the webpart will query for all items with a content type matching the selected content type. All items that have a content type that inherits from the selected type are also included in the result set.
    • Select a scope
      Limit the scope of your search query to the site of sites you want to query in.
    • Select a list
      This is an optional setting that allows you to query for items that are just in a list type of the selected type.
    • Just query on filter
      This allows you to only query for items if a filter webparts is connected and it provides a filter values. This is useful when working with large result sets. Click here for more information.
  2. Select fields
    You need to select which fields you want displayed in the grid or the calendar. Select one or more fields in the listbox on the left side of the "Select fields to be displayed" section and click "Add".
  3. Display options
    The first option to select is the grid type. You can choose for a grid of a calendar. Both options have a number of options that appear when you select a grid. A number of them are discussed here:
    • Grid - Show context menu
      Select one of the hyperlink type fields in your content type. If the grid is setup to show that hyperlink as LinkField for one of the selected fields, it will render a content menu for every item. If, for example, you configure the Title field to use "Link to item" as LinkField, and you select "Link to item" as content menu field, the title column will show a context menu for each item:
      image
    • Paging options
      Click here for more information
    • Open in a new window
      Click here for more information
    • Using the Calendar
      Click here for more information
  4. Selected field options
    After selecting a number of fields to be displayed in your webpart, you can configure a number of options for each field in the "Selected field options" section of the configuration editor.
    Please note: after changing one of the 3 options below, you need to click the "Save field" link. Otherwise your changes will not be saved to the webpart when you click OK.
    • Displayname - The displayname of the field that is used as the column header
    • LinkField - The values of the items for this field are displayed as a hyperlink. The user is redirected to the url of the field you select as the LinkField.
    • Open in new window - A new window will open when the user clicks the hyperlink configured in the previous step. Click here for more information.
    • Field order - By using the button "Move Up" and "Move Down", you can re-order the fields in your grid. This changes the column order. The buttons do not require the Save field button to be clicked.
Rollup items in a calendar

The Content By Type webpart can display items in a grid view. In version 1.2 you can also display them in a calendar view. The items that you are querying for just need (the minimum) a text field that will be used as the title and a datetime field that is used to add the item to the calendar. The screenshot below shows an example:

image

The items that are displayed in the calendar are publishing pages. The calendar allows you to display events (see this item), but it also lets you rollup any other SharePoint list item in the calendar. As long as your items have at least a text and a datetime field.

To configure the calendar to show your items, follow these steps (in the example I use the Event content type):

  1. Select your content type
    image
  2. Add the fields you need to configure the calendar to the selected fields
    image
  3. Choose "Calendar" in the "Select a grid" option list.
    image
  4. Configure the calendar. In each dropdown list select the field that you want to use for a calendar item. At least you need to select items at the Start date and Title field.
    image 
    Please note: if you are rollup up items that do not have an end date (like documents, pages, etc.), select the same datetime field as the Start date and the End date. Otherwise the calendar will assume the items have no end date, and they will be displayed on every day in the calendar.
  5. Configure the link. This link to the calendar item by default is the link to the list item that you are displaying in the calendar. If you are displaying documents in a document library, it links to the details page showing the metadata of that document. You can change this behavior by selecting a LinkField for the field that is used as the Title field (step 4). Do not forget to click "Save field".
    image

The steps above showed how to configure the calendar for event items. The configuration screen below shows the configuration how to query for all documents in your site collection and display them in a calendar view, based on when they are last modified. The highlighted parts require some attention (see the comments in the configuration steps above)

image

New Paging options

When using paging in the first release of the webpart, you had no options to configure paging. Version 1.2 now offers a number of options to setup paging for your gridview:

  • Pager Mode
  • Pager Position
  • Pager button count

These 3 options are discussed below. You can find the options in the "Display options" section of the configuration editor:

image

Pager Mode

The pager mode select box in the display options section of the configuration editor allows you to select these options:

  • Numeric (the default)
    This option uses numbers to let users select the page they want to navigate to.
    image
  • Numeric: First/Last
    Same as the previous option, but it includes a First and Last button.
    image
  • Buttons: Next/Prev
    Paging using previous/next buttons:
    image
  • Buttons: Next/Prev/First/Last
    Paging using previous and next buttons and it also includes buttons to navigate to the first and last page:
    image
  • Images: Next/Prev
    Paging using previous/next images:
    image
  • Images: Next/Prev/First/Last
    Paging using previous and next images. It also includes images to navigate to the first and last page:
    image

Pager Position

The pager controls are by default at the bottom of the grid. You can also display them on top, or at both locations:

image

Pager button count

Use this option if you are using Numeric paging. It lets you control how many numbered page links are displayed in the pager control. In this example it is set to 5 items:

image

Open links in a new window

You can configure hyperlinks in the gridview to open in a new window. You can configure this for each column that shows a hyperlink to the user. To configure this, select one of the fields you selected to display in the grid and check the checkbox "Open in new window". Obviously, this will only work if you selected one of the url fields as linkfield. Do not forget to click the "Save field" button.

image

You can also configure this for all link fields used in the webpart. This setting overrides the setting for each individual field.

image

This option can be found in the "Display options" section of the editor.

Please note: Opening links in a new window will not work for the links in the context menu. These will always open in the same window:

image

Support for hidden content types

The Content By Type WebPart support in version 1.2 a number of the content types that are hidden. You can select these content types in the group _Hidden. This allows you to query your site(s) for content of these types. The content types for these list types are now supported:

  • Calendar events
  • Blog posts
  • Blog comments
  • Wiki Pages
  • Workflow Tasks
  • Workflow History

Calendar events

Please note: Release 1.2 of the Content By Type webpart does not support recurring events. This is on the list for the next version.

The screenshot below shows an example of events:

image

In this screenshot you see the items rolled up in a grid. This content type is also easy to use with the new calendar view of the Content By Type webpart. See this item for more information.

Blog posts and comments

Using these content types allows you to rollup blog items and comments from all the blog sites in your site collection. Please note that this cannot be used to rollup blog items from users MySites. Each MySite is a separate site collection and the Content By Type webpart cannot query in other site collections.

image

Wiki Pages

See the screenshot below for an example:

image

Workflow

The webpart now makes it easy to rollup workflow tasks (and their history) in single views, to make it easier to get an overview:

image

Querying and large result sets

Depending on the configuration of your Content By Type webpart, the webpart can return very large result sets. If you select the "Item" content type and check "Include descending", you will probably get a lot of results. In this case you usually add some filter webparts to the page to make it easier for your end users to find the items that they are looking for.

The webpart now gives you the option to prevent the webpart from querying as long as no filter value is available. Initially the webpart does not query your site for items and it displays no results:

image

After selecting a filter value, the webpart will query your site(s):

image

To enable this option, check the "Just query on filter" checkbox in the configuration editor:

 image

Using the Current User Filter as filter provider

In version 1.1 of the Content By Type webpart, the current user filter could not be used as filter provider for the query webpart. This was because the webparts returned the wrong consumer parameters. This is now fixed. This means that you can read a value from the user profile and send that as filter to the content by type webpart.

The screenshot shows an example. It shows that tasks that apply to the region "East", which is the region that is stored as the sales region in my user profile.

currentuserfilter

Configuration stores names instead of IDs

In version 1.2 of the ContentByType webpart, the XML configuration stored on the webpart properties holds the internal field names of fields and the name of the selected content type. In the previous version, the ID's (Guids and ContentTypeIDs) were saved. This made it impossible to export the webpart and re-use it in another site collection. Now you can do that. And because it stored the internal field names, it also works well if you are using variations.

Another thing you can do because of this new feature is add the webpart definition to your site definitions and/or page layouts.

A quick example. First I configured my webpart to display content like this:

names1

The configuration that is stored on the webpart properties looks like the snippet below. In this snippet you will see fieldnames instead of guids. The fieldnames and the name of the selected content type are marked green.

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<DatasourceConfiguration 
 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
 xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">
  <DatasourceID>contenttype</DatasourceID>
  <GroupBy>Priority</GroupBy>
  <ItemMenu>LinkUrl</ItemMenu>
  <SortBy>TaskStatus</SortBy>
  <SortOrder>desc</SortOrder>
  <PageSize>0</PageSize>
  <MaximumItems>0</MaximumItems>
  <PagerMode>NumericButtons</PagerMode>
  <PagerPosition>Bottom</PagerPosition>
  <PageButtonCount>0</PageButtonCount>
  <GridType>SharePointGrid</GridType>
  <JustSearchOnQuery>false</JustSearchOnQuery>
  <OpenAllLinksInNewWindows>false</OpenAllLinksInNewWindows>
  <CustomProperties>
    <CustomProperty>
      <Value>MyTask</Value>
      <Id>contenttype</Id>
    </CustomProperty>
    <CustomProperty>
      <Value>false</Value>
      <Id>includedescending</Id>
    </CustomProperty>
    <CustomProperty>
      <Value>-1</Value>
      <Id>listservertemplate</Id>
    </CustomProperty>
  </CustomProperties>
  <Filters />
  <FieldReferences>
    <FieldReference>
      <OpenInNewWindow>false</OpenInNewWindow>
      <Id>Title</Id>
    </FieldReference>
    <FieldReference>
      <LinkFieldId>AssignedTo_Url</LinkFieldId>
      <OpenInNewWindow>false</OpenInNewWindow>
      <Id>AssignedTo</Id>
    </FieldReference>
    <FieldReference>
      <OpenInNewWindow>false</OpenInNewWindow>
      <Id>StartDate</Id>
    </FieldReference>
    <FieldReference>
      <OpenInNewWindow>false</OpenInNewWindow>
      <Id>TaskStatus</Id>
    </FieldReference>
  </FieldReferences>
</DatasourceConfiguration>
Using currency fields

Currency are now properly formatted in the Content By Type webpart. This applies to currency site columns that are added to a content type, and calculated fields that have 'Currency' as the result type. The screenshot below shows items of a content type that has 3 different currency fields and 1 calculated currency field.

currency1

Using calculated fields

In v1.2 of the Content By Type webpart you can also display calculated fields. In the previous version, calculated string fields of the string type appeared as 'string;#valuestring' instead of 'valuestring'. The screenshot below shows an example. It shows a number of tasks that have a calculated field that concatenates the priority and the task status values:

calculated1

This works for all result types of the calculated fields. The results are displayed in the Content By Type webpart using the display options that you have configured in your calculated fields.

Filtering

You can also connect filter webparts to your query webpart and query for values of calculated fields. The screenshot below shows you the same webpart as above, but it now has a choice filter that provides filter values to the 'PriorityStatus' field:

calculated2

Again, this works for all result types of your calculated fields.

 ‭(Hidden)‬ Admin Links