Follow us on Twitter
Follow us in Facebook
Office Dev Content
SharePoint Dev Content
Blogs for Office developers > SharePoint dev blog
You want to roll up content from your site (and subsites), no problem, CQWP is there to help.
But, hey! the tool part UI only offers support for three filters:
What if you need more filters?
One way to allow for more than three filters is to override the QueryOverride property of the web part. This involves the following general steps:
With the page in Edit Mode, expand the Content Query Web Part Menu and select Export…
Save the web part to the local file system.
If you’re not comfortable with CAML there are some tools and resources that could help:
In my site there is a custom list with the following structure and items:
If I need four filters (one for each custom column) I could use the following value in the QueryOverride property:
<property name="QueryOverride" type="string">
<FieldRef Name='NewColumn1' />
<Value Type='Text'>NewColumn1 Item1</Value>
<FieldRef Name='NewColumn2' />
<Value Type='Text'>NewColumn2 Item1</Value>
<FieldRef Name='NewColumn3' />
<Value Type='Text'>NewColumn3 Item1</Value>
<FieldRef Name='NewColumn4' />
<Value Type='Text'>NewColumn4 Item10</Value>
Note you only need the Where section of the CAML query and it has to be contained within a CDATA element.
With the web part page in Edit Mode, click the Add a Web Part link to open the Web Part Pane.
Under the Upload a Web Part section select the modified web part file in the local file system and click Upload. This will load your web part under the Imported Web Parts category.
Select your web part and click Add to import the web part into the web part page.
When we use the overrides properties within the CQWP some of the elements in the UI will be disabled, in this case we cannot add more filters from the Content Query Tool Part.