Monday, August 11, 2008

Using more than 3 filters in a CQWP

The CQWP has some limitations. One of those is that you are restricted to using no more than 3 filterfields for filtering your content. In some cases that's just not enough. There are more ways than 1 to circumvent this. The most obvious is defining a custom query in CAML (msdn). This will work very well when your webpart is to be used in one particular place and doesn't have to be customized after it's added.

However, when you want to use it in a more dynamic manner this won't do. The problem that came across my desk last week was that I had to check three boolean fields in the contenttype, and a date. The solution was to create an extra site column of the type "calculated". The value of this field was based on the other three boolean fields. Only when all three of them where false, the aggregate field would be true. Now I can filter on this field and the date field. I even have 1 filter left.

Of course, this assumes that the fields you want to use in your filter can be aggregated in a standardized way. But if that's the case, this might just save you from having to write a custom web part.

No comments:

Post a Comment

Rating