How to: Customize the Content Query Web Part by using Custom ...
Popularity Report
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
URL Tag Cloud
Bookmark History
Saved by 3 people (-2 private), first by anonymouse user on 2008-06-03
- Jeestirling on 2009-05-05 - Tags sharepoint , cqwp , caml
- Overhols on 2008-06-20 - Tags query , sharepoint , CAML , content , web , part
- Jthake on 2008-06-03 - Tags sharepoint , contentquerywebpart
Public Sticky notes
QueryOverride, ListsOverride, WebsOverride, and ViewFieldsOverride Properties
Each override property—QueryOverride, ListsOverride, WebsOverride, and ViewFieldsOverride—overrides a default Content Query Web Part behavior. To override a behavior, construct a CAML query that defines the conditions you want to set.
Note: |
|---|
| To learn more about CAML syntax and commands, see the Collaborative Application Markup Language Core Schemas in the Windows SharePoint Services 3.0 SDK. |
In the following example, we demonstrate setting custom properties for the Content Query Web Part using a CAML query. The CAML query does the following:
-
Retrieves a Created field.
-
Sets the query to retrieve items updated in the past seven days and sorts them in descending order.
-
Specifies the list type to query from.
-
Retrieves data recursively from the specified Web site and its children.
-
Retrieves values for a specific field to display for each item.
The whole query is shown, and it is described in detail in the following sections.
1 <ViewFields> 2 <FieldRef Name="Title" Nullable="True" Type="Text"/> 3 <FieldRef Name="Comments" Nullable="True" Type="Note"/> 4 </ViewFields> 5 <Lists ServerTemplate="850"></Lists> 6 <Webs Recursive="True" /> 7 <RowLimit>15</RowLimit> 8 <![CDATA[ 9 <Where> 10 <Gt> 11 <FieldRef Name="Created" Nullable="True" Type="DateTime"/> 12 <Value Type="DateTime"><Today OffsetDays="-7"/></Value> 13 </Gt> 14 </Where> 15 <OrderBy> 16 <FieldRef Name="Created" Nullable="True" Type="DateTime" 17 Ascending="FALSE"/> 18 </OrderBy>]]>
Highlighted by overhols
ListsOverride property
You can also use a CAML query to retrieve items from Windows SharePoint Services 3.0 and Office SharePoint Server 2007 lists. The following table shows three CAML statement examples that retrieve items from distinct list types.
| List Type | Property Statement |
|---|---|
| Page Libraries | Xml <![CDATA[ <Lists ServerTemplate="850"> </Lists> ]]> |
| General List base type | Xml <![CDATA[ <Lists BaseType="0"> </Lists> ]]> |
| A specific type of list | Xml <![CDATA[ <Lists> <List ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"/> </Lists> ]]> |
In the example, Line 5 defines the ListsOverride property.
5 <Lists ServerTemplate="850"></Lists>
Highlighted by overhols


Note:
Public Comment