Wednesday, August 12, 2009

Showing multiple Content Types in the Content Query WebPart

A common myth is that it is not possible to show multiple different types of content in one CQWP. The trick is that it can not be done using the web interface but can be achieved either via SharePoint Designer or by editing the source xml of the web part directly. The trick is not to think content types but list/library types. you can create a custom search query which will look in multiple different lists by the list type id and pull out the items. as long as the content types you are aggregating are related in a parent/child relationship they will be pulled together. Thus you can create a content query webpart which shows both web pages and documents in one list.

Effectively you need to add two attributes to the CQWP
ListsOverride="<Lists BaseType='1'></Lists>"

The ListsOverride is the important bit. Here I'm specifying any list which is a document library, as web pages live in document libraries it works like a charm.


Eric Zaluzec said...

Could you please be more specific on how the CQWP txts are supposed to look like. I am not having any results working.

Is it supposed to be typed in like this:

Alex Dean said...

Ah. Don't we love Totally impossible to post text which represents html markup.
Best option is to open the WebPart with SharePoint Designer and edit the properties from there.