CAML Query by Content Type Id

Almost everybody uses the Extended Content Query WebPart. Yet not many people use the QueryOverride property of the WebPart.

I want a overview of all the recently modified pages and documents in the sitecollection. Since I want to query two custom content types, I have to override the query.

<property name="QueryOverride" type="string"></property>

<Where><Or>
<BeginsWith>
<FieldRef Name='ContentTypeId' />
<Value  Type='ContentTypeId'>0x010100CustomPageContentType</Value>
</BeginsWith>
<BeginsWith>
<FieldRef Name='ContentTypeId' />
<Value Type='ContentTypeId'>0x010100CustomDocumentContentType</Value>
</BeginsWith>
</Or></Where>
<OrderBy><FieldRef Name='Modified' Ascending='False'/></OrderBy>

Special thanks to the blog post of Alex Dean.

Reacties

Populaire posts